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

6224Re: [Clip] Re: Making numbers line up

Expand Messages
  • Stephen
    Apr 2, 2001
    • 0 Attachment
      Hi Folks,
      I just had to write a clip for this too.
      Everyone had tried just about all the gambits except for manipulating
      strings so I did that.
      In my test, for 981 lines it runs two seconds slower than Wheeler's, but
      you don't have to tell the clip anything, it figures out how long lines
      should be for you, so it may all work out.
      Also for some reason or other, I could not understand the logic of the
      timer sections so in order to understand them, re-wrote them.
      Anyway for your criticism or whatever, here it is:

      H="Make numbers line up, String version"
      ^!SetListDelimiter ":"
      ^!SetArray %start%=^$GetDate(hh:mm:ss)$
      ^!SetListDelimiter ^%EMPTY%
      ^!Set %count%=1; %lastspace%=10; %wordsize%=5; %text%=^$GetText$
      ; Loop determines longest line.
      ; Loop determines longest last word
      ; Note that thisspace and thissize are not arrays, but can be treated
      like them
      ; for the purposes of this clip.
      ^!Set %temp1%=^$StrPosRight(" ";"^$GetParagraph(^%count%)$";FALSE)$
      ; Loop determines the greatest value of last space
      ^!If ^%temp1%>^%lastspace% NEXT ELSE SKIP
      ^!Set %lastspace%=^%temp1%
      ; Loop determines greatest value of wordsize
      ^!Set %temp2%=^$StrSize("^$GetParagraph(^%count%)$")$
      ^!Set %temp2%=^$Calc(^%temp2%-^%temp1%)$
      ^!If ^%temp2%>^%wordsize% NEXT ELSE SKIP
      ^!Set %wordsize%=^%temp2%
      ; Set a series of variables to hold thisspace and thissize values
      ^!Set %thisspace^%count%%=^%temp1%; %thissize^%count%%=^%temp2%
      ^!Inc %count%
      ^!If ^%count%>^$GetTextLineCount$ NEXT ELSE sizeup
      ; FORMATTING SECTION (note semicolons anywhere in the text
      ; will screw things up so we do a workaround.)
      ^!Set %counter%=0; %output%=^%EMPTY%
      ^!Set %text%="^$StrReplace("^%NL%";"; ";^%text%;FALSE;FALSE)$"
      ^!SetArray %text%=^%text%
      ^!Inc %counter%
      ^!If ^%counter% >= ^%count% writeit
      ; For each element in the text array,
      ; Loop determines how many spaces to add
      ; Loop inserts them.
      ^!Set %where%="^$StrPosRight(" ";"^%text^%counter%%";FALSE)$"
      ^!Append %output%=^%NL%^$StrInsert("^$StrFill("
      ^!GoTo format
      ^!Toolbar Clear All
      :Timer Section
      ^!SetListDelimiter ":"
      ^!SetArray %end%=^$GetDate(hh:mm:ss)$
      ^!If ^%end1%<^%start1% NEXT ELSE SKIP
      ^!Inc ^%end1% 24
      ^!Set %temp1%=^$Calc((360 * ^%start1%)+ (60 * ^%start2%)+(^%start3%))$;
      %temp2%=^$Calc((360 * ^%end1%) +(60 * ^%end2%)+(^%end3%))$
      ^!Set %totalsecs%=^$Calc(^%temp2%-^%temp1%)$
      ^!Set %hours%=^$Calc((^%totalsecs%) DIV (360))$
      ^!Set %minutes%=^$Calc((^%totalsecs% - (^%hours% * 360 )) DIV (60))$
      ^!Set %seconds%=^$Calc(^%totalsecs% - ((^%hours% * 360) + (^%minutes% *
      ^!Info Lines Formatted:^t^%NL%^%NL%^%Count%^%NL%^%NL%Start
      Time:^t^%start%^%NL%End Time:^t^%end%^%NL%Run
    • Show all 7 messages in this topic