Loading ...
Sorry, an error occurred while loading the content.

Re: Making numbers line up

Expand Messages
  • thefrank
    Hi Daniel, I found something new to me and used it to modify earlier clip. The ^$StrFill( ; )$ command automatically inserts the specified
    Message 1 of 31 , Apr 1, 2001
    • 0 Attachment
      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
      considerably.

      -------------------------------

      ^!Set %Counter%=^$GetParaCount$
      ^!Set %Count%=^$GetParaCount$
      ^!SetListDelimiter ":"
      ^!SetArray %ST%=^$GetDate(hh:nn:ss)$
      ^!Set %RightMargin%=^?[Set Right Margin nnn spaces = 45]
      ^!Jump DOC_START
      :LOOP
      ^!Set %ThisLine%=^$GetLineSize$
      ^!Set %MoveRight%=^$Calc(^%RightMargin%-^%ThisLine%)$
      ^!Jump LINE_END
      ^!MoveCursor -4
      ^!Insert ^$StrFill(^%SPACE%;^%MoveRight%)$
      ^!Dec %Counter%
      ^!If ^%Counter% > 0 NEXT else SHOWTIME
      ^!Jump +1
      ^!Goto LOOP
      :SHOWTIME
      ^!Jump LINE_END
      ^!SetArray %ET%=^$GetDate(hh:nn:ss)$
      ^!Set %Ssec%=^$Calc(^%ST3% + ^%ST2% * 60 + ^%ST1% * 3600)$
      ^!Set %Esec%=^$Calc(^%ET3% + ^%ET2% * 60 + ^%ET1% * 3600)$
      ^!If ^%Ssec%>^%Esec% ^!Inc %Esec% 86400
      ^!Set %secs%=^$Calc(^%Esec%-^%Ssec%)$
      ^!Set %hrs%=^$StrCopyRight("0^$Calc( ^%secs% DIV 3600)$";2)$
      ^!Set %min%=^$StrCopyRight("0^$Calc((^%secs%-3600*^%secs%DIV3600)
      DIV60)$";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.

      regards,

      tf
    • Phillip S. Buckland, Jr.
      ... Thanks for the memory jog! I experienced the buffering problem when porting PERL scripts from Unix to MS-DOS several years ago (Perl 4, so the details have
      Message 31 of 31 , Apr 5, 2001
      • 0 Attachment
        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's
        > >'inconsistency' You would think it would work the same as ^$GetDocName$.
        > >Actually I never bother using "^**" and always use ^$GetDocName$
        > >instead.
        >
        >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....

        Thanks for the memory jog!

        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.
      Your message has been successfully submitted and would be delivered to recipients shortly.