Align columns: Difference between revisions
Content added Content deleted
m (→(with output): changed comments, simplified some code.) |
|||
Line 6,557:
===(with output)===
<lang rexx>/*REXX program displays various alignments for words in an array of text strings. */
t.1 = "Given$a$text$file$of$many$lines,$where$fields$within$a$line$"▼
/* [↓] some "text" lines. */▼
t.2 = "are$delineated$by$a$single$'dollar'$character,$write$a$program"▼
▲t.1 = "Given$a$text$file$of$many$lines,$where$fields$within$a$line$"
t.3 = "that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$"
▲t.2 = "are$delineated$by$a$single$'dollar'$character,$write$a$program"
t.
t.5 = "Further,$allow$for$each$word$in$a$column$to$be$either$left$"▼
t.6 = "justified,$right$justified,$or$center$justified$within$its$column."▼
▲t.5 = "Further,$allow$for$each$word$in$a$column$to$be$either$left$"
▲t.6 = "justified,$right$justified,$or$center$justified$within$its$column."
_=
cols= max(cols, c)
end /*r*/
do k=1 for cols; size= size + wid.k;
rows= r -
do j=1 for 3; say;
say center(word('left right center', j) "aligned", size+cols-1, "═") /*show title*/
do
do c=1 for cols; x= @.r.c
if j==1 then _= _ left(x, wid.c) /*justified left.
if j==2 then _= _ right(x, wid.c) /* " right.
if j==3 then _= _
end /*c*/
say substr(_, 2) /*ignore the leading extra blank. */
end /*r*/
end /*j*/ /*stick a fork in it, we're all done. */</lang>
{{out|output|text= when using the default input:}}
|