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

Re: Making numbers line up

Expand Messages
  • dandiebolt@yahoo.com
    Try this. Regards, Dan ... H= Align Last Field ;initialize ^!SetWordWrap OFF ^!Set %LastLine%=^$GetLineCount$ ^!Set %FirstLine%=1 ^!Jump TEXT_START ;start
    Message 1 of 31 , Apr 1, 2001
    • 0 Attachment
      Try this.

      Regards,

      Dan
      -----------------------------------------------------
      H="Align Last Field"
      ;initialize
      ^!SetWordWrap OFF
      ^!Set %LastLine%=^$GetLineCount$
      ^!Set %FirstLine%=1
      ^!Jump TEXT_START
      ;start first pass of file
      ^!Set %CurrentLine%=1
      ^!Set %AlignmentPosition%=0
      :Loop1
      ;get length of line and whitespace trimmed line
      ^!Set %LineLength%=^$GetLineSize()$
      ^!Set %TrimLine%=^$StrTrim(^$GetLine$)$
      ^!Set %TrimLineLength%=^$StrSize(^%TrimLine%)$
      ;isolate space before last field
      ^!Set %PositionOfLastSpace%=^$StrPosRight(^%SPACE%;^%TrimLine%;False)$
      ;calculate alignment position based on lines processed so far
      ^!Set %AlignmentPosition%=^$Calc(max(^%AlignmentPosition%;^%
      PositionOfLastSpace%))$
      ;test if loop continutes
      ^!Inc %CurrentLine%
      ^!Jump ^%CurrentLine%
      ^!If ^%CurrentLine% <= ^%LastLine% Loop1
      ;start second pass of file
      ^!Jump TEXT_START
      ^!Set %CurrentLine%=1
      :Loop2
      ;get length of line and white space trimmed line
      ^!Set %LineLength%=^$GetLineSize()$
      ^!Set %TrimLine%=^$StrTrim(^$GetLine$)$
      ^!Set %TrimLineLength%=^$StrSize(^%TrimLine%)$
      ;isolate last word and get length
      ^!Set %PositionOfLastSpace%=^$StrPosRight(^%SPACE%;^%TrimLine%;False)$
      ;calculate padding need to bring this line into alignment
      ^!Set %PaddingNeeded%=^$Calc(^%AlignmentPosition% - ^%
      PositionOfLastSpace%)$
      ;insert the padding
      ^!Set %Padding%=^$StrFill(^%SPACE%;^%PaddingNeeded%)$
      ^!Set %NewLine%=^$StrInsert(^%Padding%;^%TrimLine%;^%
      PositionOfLastSpace%)$
      ;replace the curent line with ^%NewLine%
      ^!SetClipboard ^%NewLine%^%NL%
      ^!Select LINE
      ^!Toolbar Paste
      ;test if loop continutes
      ^!Inc %CurrentLine%
      ^!Jump ^%CurrentLine%
      ^!If ^%CurrentLine% <= ^%LastLine% Loop2
    • 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.