/* REXX BLOX create block letters from an input string. for each of eight lines for each letter in string get pattern for letter get sub-pattern for this line build slug attach to line write the line Use '(routine name) ?' for HELP-text. Written by Frank Clarke (F1111), rexxhead@yahoo.com, 1991-04-17 Impact Analysis . SYSEXEC TRAPOUT Modification History 20230528 fxc REXXSKEL at last; 20230712 fxc fix NOVALUE on 'sav' 20230806 fxc chg SYSPROC to SYSEXEC in Impact Analysis; 20231005 fxc blank if short string; 20240414 fxc DUMP_QUEUE quiet; */ arg argline address TSO arg parms "((" opts signal on syntax signal on novalue call TOOLKIT_INIT /* conventional start-up -*/ rc = Trace("O"); rc = Trace(tv) info = parms /* to enable parsing */ call A_INIT /* -*/ call B_LETTERS /* -*/ if \sw.0nested then call DUMP_QUEUE 'quiet' /* -*/ exit /*@ BLOX */ /* . ----------------------------------------------------------------- */ A_INIT: /*@ */ if branch then call BRANCH address TSO parse value "" with sav instr = Strip( info ) /* clean the input */ if instr <> "" then prompt = 0 if odsn <> "" then do /* was a value */ alloc.0 = "NEW CATALOG UNIT(SYSDA) SPACE(5 5) TRACKS", "RECFM(V B) LRECL(32760) BLKSIZE(0)" alloc.1 = "SHR" /* if it already exists... */ tempstat = Sysdsn( odsn ) = "OK" |, /* 1=exists, 0=missing */ Sysdsn( odsn ) = "MEMBER NOT FOUND" "ALLOC FI( BLOXDD ) DA(" odsn ") REU" alloc.tempstat end /* alloc dataset */ else "ALLOC FI(BLOXDD) DA(*) SHR REU" /* to the terminal */ return /*@ A_INIT */ /* . ----------------------------------------------------------------- */ B_LETTERS: /*@ */ if branch then call BRANCH address TSO b_tv = trace() /* what setting at entry ? */ rc = Trace("O") rc = trace( b_tv ) call SET_PATN /* -*/ if tv = "N" then "CLEAR" /* clear screen */ if instr = "" then do /* no input ? */ say ":" /* initial prompt */ "NEWSTACK" pull instr "DELSTACK" end "NEWSTACK" do forever do while instr <> "" if length(instr) > 8 then do /* too long */ pt = LastPos( " ",instr" ",8 ) if pt > 0 then parse var instr instr =(pt) sav else parse var instr instr 9 sav /* save the excess */ end else sav = '' do i = 1 to 7 /* for 7 lines */ outline="" /* clear it */ do j = 1 to Length(instr) /* for each letter */ ltr = Substr(instr,j,1) /* isolate it */ ltrpos = Pos(ltr,choices) /* where in the array ? */ if ltrpos = 0 then ltrpos = 46 /* set to blank */ byte = Substr(patn.ltrpos,i*2-1,2) if diagnose then say ltr byte X2B(byte) slug = X2B(byte) /* character-to-binary */ slug = Translate(slug," ","0") /* off -> blank */ slug = Translate(slug,ltr,"1") /* on -> letter */ outline = outline slug /* splice to the line */ end /* j for length(instr) */ rc = Trace("O") rc = trace( b_tv ) queue outline /* into the queue */ end /* i for 7 lines */ instr = Strip( sav ) /* restore it */ queue " " /* blank line */ queue " " /* blank line */ end /* while instr filled */ if prompt then, if instr = "" then do /* no more input ? */ say ":" /* prompt for more */ "NEWSTACK" pull instr "DELSTACK" end if instr = "" then leave /* prompt was refused */ end /* forever */ rc = Trace("O") rc = trace( b_tv ) "EXECIO" queued() "DISKW BLOXDD (FINIS" /* flush to output */ "DELSTACK" "FREE FI(BLOXDD)" return /*@ B_LETTERS */ /* . ----------------------------------------------------------------- */ SET_PATN: /*@ */ patn.="" /* storage for patterns */ patn.1 = "081422417F4141" /* A */ patn.2 = "7E41417E41417E" /* B */ patn.3 = "3E41404040413E" /* C */ patn.4 = "7C42414141427C" /* D */ patn.5 = "7F40407C40407F" /* E */ patn.6 = "7F40407C404040" /* F */ patn.7 = "3E41404047413E" /* G */ patn.8 = "4141417F414141" /* H */ patn.9 = "1C08080808081C" /* I */ patn.10 = "7F02020202423C" /* J */ patn.11 = "41424478444241" /* K */ patn.12 = "4040404040407F" /* L */ patn.13 = "41635549414141" /* M */ patn.14 = "41615149454341" /* N */ patn.15 = "3E41414141413E" /* O */ patn.16 = "7E41417E404040" /* P */ patn.17 = "3E41414145423D" /* Q */ patn.18 = "7E41417E444241" /* R */ patn.19 = "3E41403E01413E" /* S */ patn.20 = "7F080808080808" /* T */ patn.21 = "4141414141413E" /* U */ patn.22 = "41414141221408" /* V */ patn.23 = "41414141494936" /* W */ patn.24 = "41221408142241" /* X */ patn.25 = "41221408080808" /* Y */ patn.26 = "7F02040810207F" /* Z */ patn.27 = "3E43454951613E" /* 0 */ patn.28 = "0818080808083E" /* 1 */ patn.29 = "3E41020408103E" /* 2 */ patn.30 = "7F020C0201413E" /* 3 */ patn.31 = "2040487F080808" /* 4 */ patn.32 = "7F40407E01017E" /* 5 */ patn.33 = "0408103E41413E" /* 6 */ patn.34 = "7F020408080808" /* 7 */ patn.35 = "3E41413E41413E" /* 8 */ patn.36 = "3E41413E040810" /* 9 */ patn.37 = "22227F227F2222" /* # */ patn.38 = "143E403E013E14" /* $ */ patn.39 = "21522408122542" /* % */ patn.40 = "0018241825423D" /* & */ patn.41 = "0022143E142200" /* * */ patn.42 = "04081010100804" /* ( */ patn.43 = "10080404040810" /* ) */ patn.44 = "0000003E000000" /* - */ patn.45 = "00181800181800" /* : */ patn.46 = "00000000000000" /*blank */ patn.47 = "00181800181808" /* ; */ patn.48 = "3E410104080008" /* ? */ patn.49 = "18181818180018" /* ! */ choices ="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789#$%&*()-: ;?!" return /*@ SET_PATN */ /* . ----------------------------------------------------------------- */ LOCAL_PREINIT: /*@ customize opts */ address TSO odsn = KEYWD("OUTPUT") /* output to file ? */ if Pos("(",odsn) > 0 then, /* has a left banana */ if Pos(")",odsn) = 0 then, /* but no right banana */ odsn = Space(odsn")",0) /* add one */ prompt = SWITCH("NOPROMPT") = 0 diagnose = SWITCH("DIAGNOSE") return /*@ LOCAL_PREINIT */ /* subroutines below LOCAL_PREINIT are not selected by SHOWFLOW */ /* . ----------------------------------------------------------------- */ HELP: /*@ */ address TSO;"CLEAR" if helpmsg <> "" then say helpmsg ex_nam = Left(exec_name,8) /* predictable size */ say " " say " "ex_nam" is a REXX routine which will build 8x7 block letters from " say " text you specify. It is patterned after IBM's block " say " letter writer, IEFSD095. " say " " say " "exec_name" can output strings to length=8 and writes to " say " the screen-face or to a file you name. If an input string" say " is longer than 8, the excess is written on subsequent " say " lines. Syntax for "exec_name" is: " say " " say " Syntax: "ex_nam" string " say " (( OUTPUT dsname " say " DIAGNOSE " say " NOPROMPT " say " " say " string is the text to be produced as block letters. " say " " say " more... " "NEWSTACK"; pull ; "CLEAR" ; "DELSTACK" say " " say " dsname identifies a dataset on which the block letters " say " will be written. " say " If not specified, output is to the terminal. " say " " say " DIAGNOSE displays the letter being formed, and the bit " say " pattern being used for each line. " say " " say " NOPROMPT if specified, suppresses prompting for a 2nd or " say " subsequent line of text. " "NEWSTACK"; pull ; "CLEAR" ; "DELSTACK" say " " say " Debugging tools provided include: " say " " say " BRANCH: show all paragraph entries. " say " " say " TRACE tv: will use value following TRACE to place the execution " say " into REXX TRACE Mode. " say " " say " " say " Debugging tools can be accessed in the following manner: " say " " say " TSO "ex_nam" parameters (( debug-options " say " " say " For example: " say " " say " TSO "ex_nam" (( BRANCH TRACE ?R " if sw.0inispf then, address ISPEXEC "CONTROL DISPLAY REFRESH" exit /*@ HELP */ /* . ----------------------------------------------------------------- */ BRANCH: Procedure expose, /*@ */ sigl exec_name rc = trace("O") /* we do not want to see this */ arg brparm . origin = sigl /* where was I called from ? */ do currln = origin to 1 by -1 /* inch backward to label */ if Right(Word(Sourceline(currln),1),1) = ":" then do parse value sourceline(currln) with pgfname ":" . /* Label */ leave ; end /* name */ end /* currln */ select when brparm = "NAME" then return(pgfname) /* Return full name */ when brparm = "ID" then do /* wants the prefix */ parse var pgfname pgfpref "_" . /* get the prefix */ return(pgfpref) end /* brparm = "ID" */ otherwise say left(sigl,6) left(pgfname,40) exec_name "Time:" time("L") end /* select */ return /*@ BRANCH */ /* . ----------------------------------------------------------------- */ DUMP_QUEUE: /*@ Take whatever is in stack */ rc = trace("O") /* and write to the screen */ address TSO arg mode . "QSTACK" /* how many stacks? */ stk2dump = rc - tk_init_stacks /* remaining stacks */ if stk2dump = 0 & queued() = 0 then return if mode <> "QUIET" then, say "Total Stacks" rc , /* rc = #of stacks */ " Begin Stacks" tk_init_stacks , /* Stacks present at start */ " Excess Stacks to dump" stk2dump do dd = rc to tk_init_stacks by -1 /* empty each one. */ if mode <> "QUIET" then, say "Processing Stack #" dd " Total Lines:" queued() do queued();parse pull line;say line;end /* pump to the screen */ "DELSTACK" /* remove stack */ end /* dd = 1 to rc */ return /*@ DUMP_QUEUE */ /* Handle CLIST-form keywords added 20020513 . ----------------------------------------------------------------- */ CLKWD: Procedure expose info /*@ hide all except info */ arg kw kw = kw"(" /* form is 'KEY(DATA)' */ kw_pos = Pos(kw,info) /* find where it is, maybe */ if kw_pos = 0 then return "" /* send back a null, not found*/ rtpt = Pos(") ",info" ",kw_pos) /* locate end-paren */ slug = Substr(info,kw_pos,rtpt-kw_pos+1) /* isolate */ info = Delstr(info,kw_pos,rtpt-kw_pos+1) /* excise */ parse var slug (kw) slug /* drop kw */ slug = Reverse(Substr(Reverse(Strip(slug)),2)) return slug /*@CLKWD */ /* Handle multi-word keys 20020513 . ----------------------------------------------------------------- */ KEYWD: Procedure expose info /*@ hide all vars, except info*/ arg kw kw_pos = wordpos(kw,info) /* find where it is, maybe */ if kw_pos = 0 then return "" /* send back a null, not found*/ kw_val = word(info,kw_pos+Words(kw))/* get the next word */ info = Delword(info,kw_pos,2) /* remove both */ return kw_val /*@ KEYWD */ /* . ----------------------------------------------------------------- */ KEYPHRS: Procedure expose, /*@ */ info helpmsg exec_name /* just these three */ arg kp wp = wordpos(kp,info) /* where is it? */ if wp = 0 then return "" /* not found */ front = subword(info,1,wp-1) /* everything before kp */ back = subword(info,wp+1) /* everything after kp */ parse var back dlm back /* 1st token must be 2 bytes */ if length(dlm) <> 2 then /* Must be two bytes */ helpmsg = helpmsg, "Invalid length for delimiter("dlm") with KEYPHRS("kp")", info if wordpos(dlm,back) = 0 then /* search for ending delimiter*/ helpmsg = helpmsg, "No matching second delimiter("dlm") with KEYPHRS("kp")", info if helpmsg <> "" then call HELP /* Something is wrong */ parse var back kpval (dlm) back /* get everything b/w delim */ info = front back /* restore remainder */ return Strip(kpval) /*@ KEYPHRS */ /* . ----------------------------------------------------------------- */ NOVALUE: /*@ */ say exec_name "raised NOVALUE at line" sigl say " " say "The referenced variable is" condition("D") say " " zsigl = sigl signal SHOW_SOURCE /*@ NOVALUE */ /* . ----------------------------------------------------------------- */ SHOW_SOURCE: /*@ */ call DUMP_QUEUE /* Spill contents of stacks -*/ if sourceline() <> "0" then /* to screen */ say sourceline(zsigl) rc = trace("?R") nop exit /*@ SHOW_SOURCE */ /* . ----------------------------------------------------------------- */ SS: Procedure /*@ Show Source */ arg ssbeg ssend . if ssend = "" then ssend = 10 if \datatype(ssbeg,"W") | \datatype(ssend,"W") then return ssend = ssbeg + ssend do ssii = ssbeg to ssend ; say Strip(sourceline(ssii),'T') ; end return /*@ SS */ /* . ----------------------------------------------------------------- */ SWITCH: Procedure expose info /*@ */ arg kw sw_val = Wordpos(kw,info) > 0 /* exists = 1; not found = 0 */ if sw_val then /* exists */ info = Delword(info,Wordpos(kw,info),1) /* remove it */ return sw_val /*@ SWITCH */ /* . ----------------------------------------------------------------- */ SYNTAX: /*@ */ errormsg = exec_name "encountered REXX error" rc "in line" sigl":", errortext(rc) say errormsg zsigl = sigl signal SHOW_SOURCE /*@ SYNTAX */ /* Can call TRAPOUT. . ----------------------------------------------------------------- */ TOOLKIT_INIT: /*@ */ address TSO info = Strip(opts,"T",")") /* clip trailing paren */ parse source sys_id how_invokt exec_name DD_nm DS_nm, as_invokt cmd_env addr_spc usr_tokn parse value "" with tv helpmsg . parse value 0 "ISR00000 YES" "Error-Press PF1" with, sw. zerrhm zerralrm zerrsm if SWITCH("TRAPOUT") then do "TRAPOUT" exec_name parms "(( TRACE R" info exit end /* trapout */ sw.0nested = sysvar("SYSNEST") = "YES" sw.0batch = sysvar("SYSENV") = "BACK" sw.0inispf = sysvar("SYSISPF") = "ACTIVE" if Word(parms,1) = "?" then call HELP /* I won't be back */ "QSTACK" ; tk_init_stacks = rc /* How many stacks? */ parse value SWITCH("BRANCH") SWITCH("MONITOR") SWITCH("NOUPDT") with, branch monitor noupdt . parse value mvsvar("SYSNAME") sysvar("SYSNODE") with, #tk_cpu node . parse value KEYWD("TRACE") "N" with tv . tk_globalvars = "exec_name tv helpmsg sw. zerrhm zerralrm ", "zerrsm zerrlm tk_init_stacks branch monitor ", "noupdt" call LOCAL_PREINIT /* for more opts -*/ return /*@ TOOLKIT_INIT */ /* Work area for creating new patterns: */ /* 0....... */ /* 0....... */ /* 0....... */ /* 0....... */ /* 0....... */ /* 0....... */ /* 0....... */ /* 0....... */