Re: Making numbers line up
- Hi Daniel,
I found something new to me and used it to modify earlier clip.
The ^$StrFill(<character>;<nnn times>)$ command automatically inserts
the specified character as many times as you say. This eliminates the
need for Keyboard command and speeds up the clip operation
^!Set %RightMargin%=^?[Set Right Margin nnn spaces = 45]
^!If ^%Counter% > 0 NEXT else SHOWTIME
^!Set %Ssec%=^$Calc(^%ST3% + ^%ST2% * 60 + ^%ST1% * 3600)$
^!Set %Esec%=^$Calc(^%ET3% + ^%ET2% * 60 + ^%ET1% * 3600)$
^!If ^%Ssec%>^%Esec% ^!Inc %Esec% 86400
^!Set %hrs%=^$StrCopyRight("0^$Calc( ^%secs% DIV 3600)$";2)$
^!Set %sec%=^$StrCopyRight("0^$Calc( ^%secs% MOD 60)$";2)$
^!Info Lines Formatted:^t^%NL%^%NL%^%Count%^%NL%^%NL%Start Time:^t^%
ST%^%NL%End Time:^t^%ET%^%NL%Run Time:^t^%hrs%:^%min%:^%sec%
(watch for and unwrap wrapped lines)
I added the timer elements built from the *FindStringDelete* caper a
couple of weeks ago. If you format many documents this way, you
could, at the end of the clip, add code to insert the *Formatted
Lines* amount into another doc and keep a running total of all the
lines from several docs, and otherwise log activity.
The above formats 1000 lines of your example in 22 seconds; the
earlier clip took 4min 19sec to achieve the same result.
This clip makes the same assumptions as the earlier one, with one
addition: The text in the document must, however, end at the end of
the last line (no additional line returns after last text) or there
will be a minor glitch on the last line. I'm not sure how to repair
that, but I am confident someone else will have that answer.
- At 10:20 PM 4/4/01, Jason Waugh wrote:
> >I don't know the intricacies of using ^** you might have a point about it'sThanks for the memory jog!
> >'inconsistency' You would think it would work the same as ^$GetDocName$.
> >Actually I never bother using "^**" and always use ^$GetDocName$
>Well, it's not so much an inconsistency with ^** as it is an inconsistency
>in the way NoteTab and Perl are working together with respect to
>STDERR. Maybe Perl isn't flushing before NoteTab thinks it's done
>capturing STDERR? Maybe the NoteTab parser occasionally chokes on parsing
>^**? This would result in the two different error messages appearing on
>different tries with the same script....
I experienced the buffering problem when porting PERL scripts from Unix to
MS-DOS several years ago (Perl 4, so the details have changed about
avoiding the problem since I wrote those scripts). I recall needing to
either disable buffering, or set it to line buffering (from block
buffering) to make the problem go away.
Find a Perl reference (here's one I have: "Programming Perl", second
edition, by Larry Wall, Tom Christiansen & Randal L. Schwartz, published by
O'Reilly, copyright 1996) and look for information on the "$|"
variable. It allows you to set output filehandles to block buffering
(default) or line buffering (which is needed for Perl with NoteTab, since
it runs as a DOS program).
Hope this is helpful.