Align columns: Difference between revisions
Content deleted Content added
Line 3,629: | Line 3,629: | ||
for y = 0 to Tally(Line, "$") |
for y = 0 to Tally(Line, "$") |
||
LWord = Field$(Line, "$", y+1) |
LWord = Field$(Line, "$", y+1) |
||
NrSpaces = ColWidth(y) - len(LWord) |
|||
'left align |
'left align |
||
TextLeft = TextLeft + LWord + String$(NrSpaces +1, " ") |
|||
TextLeft = TextLeft + AWord |
|||
'Right align |
'Right align |
||
TextRight = TextRight + String$(NrSpaces +1, " ") + LWord |
|||
TextRight = TextRight + AWord |
|||
'Center |
'Center |
||
TextCenter = TextCenter + String$(floor((NrSpaces)/2)+1, " ") + LWord + string$(Ceil((NrSpaces)/2), " ") |
|||
AWord = String$(floor(NrSpaces)+1, " ") + LWord + string$(Ceil(NrSpaces), " ") |
|||
TextCenter = TextCenter + AWord |
|||
next |
next |
||
TextLeft = TextLeft + Newline |
TextLeft = TextLeft + Newline |
||
Line 3,647: | Line 3,644: | ||
Sample output: |
Sample output: |
||
<pre style="height: |
<pre style="height:20ex;overflow:scroll">TextLeft contains: |
||
Given a text file of many lines, where fields within a line |
Given a text file of many lines, where fields within a line |
||
are delineated by a single 'dollar' character, write a program |
are delineated by a single 'dollar' character, write a program |