Anonymous user
Align columns: Difference between revisions
m
→(boxed output): added/changed come comments, added whitespace.
m (→(with output): changed comments, simplified some code.) |
m (→(boxed output): added/changed come comments, added whitespace.) |
||
Line 6,616:
===(boxed output)===
Note:
<lang rexx>/*REXX
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 r=0 to rows; _=;
do c=1 for cols; x= @.r.c
if r==0 then x= copies("─", wid.c + 1)
if j==1 then _= _ || ! || left(x, wid.c) /*justify left*/
if j==2 then _= _ || ! || right(x, wid.c) /* " ruggt*/
if j==3 then _= _ || ! ||
end /*c*/
if r==0 then do; _= '┌'substr(_, 2, length(_) - 1)"┐" /*top line.*/
bot= '└'substr(_, 2, length(_) - 2)"┘" /*bot " */
end
else _= _ || ! /*append trailing end boxing character.*/
say _
end /*r*/ /* [↑] shows words in boxes. */
say translate(bot, '┴', "┬") /*display the bottom line of the box. */
end /*j*/ /*stick a fork in it, we're all done. */</lang>
{{out|output|text= when using the default input:}}
|