/* REXX COLFORM Demonstrates a method for stacking items in columns. This demo uses one-word tokens and arranges them with the first n-tokens in column 1, the next n tokens in column 2, &c. If something other than single tokens is to be stacked, this logic may require tweaking. . Further, unless there exists exactly (rows x columns) tokens to be stacked, the last column will be partially filled, and some row (or rows) will appear to be truncated. */ address ISREDIT "MACRO (opts)" if rc = 20 then do /* ISREDIT not available */ address TSO parse source . . exec_name . ex_nam = Left(exec_name,8) /* predictable size */ helpmsg = ex_nam "is an EDIT macro" say helpmsg end upper opts parse var opts parms "((" opts opts = Strip( opts,'T',')' ) /* yes we want no bananas */ parse value "" with tv parse var opts "TRACE" tv . parse value tv "N" with tv . rc = Trace('O') ; rc = Trace(tv) parse value "0" with sw. . sw.0notes = WordPos( "NOTES",parms ) > 0 call A_INIT /* -*/ call F_FORMAT /* -*/ exit /*@ COLFORM */ /* . ----------------------------------------------------------------- */ A_INIT: /*@ */ address TSO call AD_GET_DS /* -*/ parse value "" with, tokenlist . if mbr = "" then dsspec = "'"dsn"'" else dsspec = "'"dsn"("mbr")'" "ALLOC FI( @TMP ) DA( " dsspec ") SHR REU " "NEWSTACK" "EXECIO * DISKR @TMP ( FINIS " do queued() pull line tokenlist = tokenlist line end /* queued */ "DELSTACK" tokenlist = Space( tokenlist,1 ) maxlen = 1 w1 = "" do Words( tokenlist ) parse value tokenlist w1 with w1 tokenlist maxlen = Max( Length( w1 ),maxlen ) end /* tokenlist */ tokenlist = tokenlist w1 /* restore */ tokenct = Words( tokenlist ) /* How many tokens? */ colsize = maxlen + 4 /* add some spacing */ colcount = dataw % colsize /* How many columns? */ depth = (tokenct + colcount - 1)%colcount /* How many rows? */ if sw.0notes then do say tokenct "tokens, the maximum length is" maxlen say colcount "columns can fit across this screen." say "The column-depth is" depth end /* arrange the tokens into columns: 1:n, n+1:2n, 2n+1:3n, etc. */ parse value "0" with, toks line. do colcount /* each column */ do rr = 1 to depth /* each row */ parse var tokenlist w1 tokenlist line.rr = line.rr Left( w1,colsize ) toks = toks + 1 if toks = tokenct then leave /* no more left */ end /* depth */ end /* colcount */ return /*@ A_INIT */ /* Isolate dsn and mbr . ----------------------------------------------------------------- */ AD_GET_DS: /*@ */ address ISREDIT "(dsn) = DATASET " "(mbr) = MEMBER " "(dataw) = DATA_WIDTH" return /*@ AD_GET_DS */ /* . ----------------------------------------------------------------- */ F_FORMAT: /*@ */ address ISREDIT /* "F p'^' FIRST" "LABEL .zcsr = .A " */ "X ALL" do rr = 1 to depth /* write the rows */ line.rr = Strip( line.rr ) /* leading and trailing */ txt = line.rr /* "LINE_BEFORE .A = (txt) " */ "LINE_AFTER .zl = (txt) " end /* rr */ return /*@ F_FORMAT */