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

Expand Messages
• Apr 2, 2001
• 0 Attachment
Hi Folks,
I just had to write a clip for this too.
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\$
:sizeup
; 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%
:format
^!Inc %counter%
^!If ^%counter% >= ^%count% writeit
; For each element in the text array,
; Loop determines how many spaces to add
^!Set
; Loop inserts them.
^!Set %where%="^\$StrPosRight(" ";"^%text^%counter%%";FALSE)\$"
^!Append %output%=^%NL%^\$StrInsert("^\$StrFill("
^!GoTo format
:writeit
^!Toolbar Clear All
^%output%
: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% *
60)))\$
^!Info Lines Formatted:^t^%NL%^%NL%^%Count%^%NL%^%NL%Start
Time:^t^%start%^%NL%End Time:^t^%end%^%NL%Run
Time:^t^%hours%:^%minutes%:^%seconds%
• Show all 7 messages in this topic