Another update from ingydotnet^djgoku

This commit is contained in:
Ingy döt Net 2015-11-18 06:14:39 +00:00
parent 91df62d461
commit 948b86eafa
7604 changed files with 108452 additions and 22726 deletions

View file

@ -1,83 +1,60 @@
/*REXX program displays a 12x12 multiplication boxed grid table, grid */
/* will be displayed in "boxing" characters for ASCII or EBCDIC.*/
parse arg high . /*get optional grid size from CL.*/
if high=='' then high=12 /*not specified? Use default. */
ebcdic= 'f0'==1 /*is this an EBCDIC machine? */
/*REXX program displays a NxN multiplication table (in a boxed grid). */
parse arg high . /*get optional grid size from the C.L. */
if high=='' then high=12 /*Not specified? Then use the default.*/
bar = '' ; dash = '' /*(vertical) bar; horizontal bar (dash)*/
bj = '' ; tj = '' /*bottom and top junctions (or tees).*/
cj = '' /*center junction (or cross). */
lj = '' ; rj = '' /*left and right junctions (or tees).*/
tlc = '' ; trc = '' /* top left and right corners. */
blc = '' ; brc = '' /*bottom " " " " */
/* [↑] define stuff to hold box glyphs*/
cell = cj || copies(dash, 5) /*define the top of the cell. */
sep = copies(cell, high+1)rj /*build the table separator. */
sepL = length(sep) /*length of the separator line. */
width= length(cell)-1 /*width of the table cells. */
size = width-1 /*width for the table numbers. */
box. = left('', width) /*construct all the cells. */
if ebcdic then do /*══════════EBCDIC═══════════════*/
bar='fa'x /*vertical bar. */
dash='bf'x /*horizontal dash. */
bj ='cb'x /*bottom junction. */
tj ='cc'x /* top junction. */
cj ='8f'x /*center junction (cross). */
lj ='eb'x /* left junction. */
rj ='ec'x /* right junction. */
tlc='ac'x /*top left corner. */
trc='bc'x /*top right corner. */
blc='ab'x /*bottom left corner. */
brc='bb'x /*bottom right corner. */
end
else do /*══════════ASCII════════════════*/
bar='b3'x /*vertical bar. */
dash='c4'x /*horizontal dash. */
bj ='c1'x /*bottom junction. */
tj ='c2'x /* top junction. */
cj ='c5'x /*center junction (cross). */
lj ='c3'x /* left junction. */
rj ='b4'x /* right junction. */
tlc='da'x /*top left corner. */
trc='bf'x /*top right corner. */
blc='c0'x /*bottom left corner. */
brc='d9'x /*bottom right corner. */
end
do j=0 to high /*step through zero ───► high. */
_=right(j, size-1)'x ' /*build the "label" (border) number. */
box.0.j=_ /*build the top label cell. */
box.j.0=_ /*build the left label cell. */
end /*j*/
cell=cj || copies(dash,5) /*define the top of the cell. */
sep=copies(cell,high+1)rj /*build the table separator. */
sepL=length(sep) /*length of separator line. */
width=length(cell)-1 /*width of the table cells. */
size=width-1 /*width for table numbers. */
box.=left('',width) /*construct all the cells. */
box.0.0=centre('times', width) /*redefine box.0.0 with 'X'. */
do j=0 to high /*step through zero to H (12). */
_=right(j,size-1)'x ' /*build "label"/border number. */
box.0.j=_ /*build top label cell. */
box.j.0=_ /*build left label cell. */
end /*j*/
box.0.0=centre('times',width) /*redefine box.0.0 with 'X'. */
do row=1 for high /*step through 1 to H (12). */
do col=row to high /*step through row to H (12). */
box.row.col=right(row*col,size)' ' /*build a mult. cell. */
do row=1 for high /*step through one ───► high. */
do col=row to high /*step through row ───► high. */
box.row.col=right(row*col, size)' ' /*build a multiplication cell. */
end /*col*/
end /*row*/
do row=0 to high /*step through all the lines. */
asep=sep /*allow use of a modified sep. */
do row=0 to high /*step through all the lines. */
asep=sep /*allow use of a modified separator. */
if row==0 then do
asep=overlay(tlc,asep,1) /*make a better tlc. */
asep=overlay(trc,asep,sepL) /*make a better trc. */
asep=translate(asep,tj,cj) /*make a better tj. */
asep=overlay(tlc, asep, 1) /*make a better tlc. */
asep=overlay(trc, asep, sepL) /*make a better trc. */
asep=translate(asep, tj ,cj) /*make a better tj. */
end
else asep=overlay(lj,asep,1) /*make a better lj. */
else asep=overlay(lj, asep ,1) /*make a better lj. */
say asep /*display a table grid line. */
if row==0 then call buildLine 00 /*display a blank grid line. */
call buildLine row /*build one line of the grid. */
if row==0 then call buildLine 00 /*display a blank grid line. */
say asep /*display a table grid line. */
if row==0 then call buildLine 00 /*display a blank grid line. */
call buildLine row /*build one line of the grid. */
if row==0 then call buildLine 00 /*display a blank grid line. */
end /*row*/
asep=sep /*allow use of a modified sep. */
asep=overlay(blc,asep,1) /*make a better bot left corner.*/
asep=overlay(brc,asep,sepL) /*make a better bot right corner.*/
asep=translate(asep,bj,cj) /*make a better bot junction. */
say asep /*display a table grid line. */
exit /*stick a fork in it, we're done.*/
/*──────────────────────────────────BUILDLINE subroutine────────────────*/
buildLine: w=; parse arg arow /*start with a blank cell. */
asep=sep /*allow use of a modified separator. */
asep=overlay(blc, asep, 1) /*make a better bottom left corner. */
asep=overlay(brc, asep, sepL) /*make a better bottom right corner. */
asep=translate(asep, bj, cj) /*make a better bottom junction. */
say asep /*display a table grid line. */
exit /*stick a fork in it, we're all done. */
/*────────────────────────────────────────────────────────────────────────────*/
buildLine: w=; parse arg arow /*start with a blank cell. */
do col=0 to high /*step through 0 to H (12). */
w=w||bar||box.arow.col /*build one cell at a time. */
do col=0 to high /*step through zero ───► high. */
w=w||bar||box.arow.col /*build one cell at a time. */
end /*col*/
say w || bar /*finish building the last cell. */
say w || bar /*finish building the last cell. */
return