/* REXX TBLGEN TBCREATE a new table of type AATBLID according to specifics stored in AAMSTR, the Master Table-of-Tables. The structure of AAMSTR is: Variable T Example (for the AA-row) -------- - ------------------- AATBLID K AA (for the AAMSTR table itself) AATBLNM N AAMSTR AAKEYS N AATBLID AANAMES N AATBLNM AADESC AAKEYS AANAMES AASORT AASORT N AATBLID,C,A AADESC N Master Table AALIBR N Canonical Table Location Written by Frank Clarke, Oldsmar FL, 19980528 rexxhead@yahoo.com Impact Analysis . SYSPROC DFLTTLIB . SYSPROC TRAPOUT Modification History 20010223 fxc finally added help-text for DESCRIBE; wrapped CLEAR commands with NEWSTACK/DELSTACK; 20010720 fxc WIDEHELP; */ address ISPEXEC /* REXXSKEL ver.19980225 */ arg parms "((" opts signal on syntax signal on novalue call TOOLKIT_INIT /* conventional start-up -*/ rc = trace(tv) info = parms /* to enable parsing */ "CONTROL ERRORS RETURN" call A_INIT /* -*/ call B_READ_MSTR /* -*/ if \sw.0error_found then, call C_BUILD /* -*/ if \sw.nested then call DUMP_QUEUE /* -*/ exit /*@ TBLGEN */ /* . ----------------------------------------------------------------- */ A_INIT: /*@ */ if branch then call BRANCH address TSO /* "SYSUMON USER" Userid() "TOOL" exec_name */ call AA_KEYWDS /* -*/ openmode.0 = "WRITE" /* based on NOUPDT */ openmode.1 = "NOWRITE" return /*@ A_INIT */ /* . ----------------------------------------------------------------- */ AA_KEYWDS: /*@ */ if branch then call BRANCH address ISPEXEC tblnm = KEYWD("TBLNAME") sw.0testmode = SWITCH("TEST") sw.0describe = SWITCH("DESCRIBE") parse var info aatblid genparms return /*@ AA_KEYWDS */ /* Get the TBCREATE info from table AAMSTR . ----------------------------------------------------------------- */ B_READ_MSTR: /*@ */ if branch then call BRANCH address ISPEXEC "LIBDEF ISPTLIB DATASET ID("isptlib") STACK" "TBSTATS" $aa$ "STATUS1(s1) STATUS2(s2)" if s1 > 1 then do say "Table" $aa$ "not available." exit end; else, if s2 = 1 then, /* not open */ "TBOPEN " $aa$ "NOWRITE" else "TBTOP" $aa$ "LIBDEF ISPTLIB" "TBGET" $aa$ /* aatblid is already set */ if rc > 0 then do zerrsm = "TBGET failed for key="aatblid zerrlm = exec_name "("BRANCH("ID")")", "Row not found for ID" aatblid, "in "Strip(isptlib,,"'")"("$aa$").", " Are you using the correct ISPTLIB dataset?" address ISPEXEC "SETMSG MSG(ISRZ002)" if monitor then say zerrlm sw.0error_found = "1" end "TBEND" $aa$ /* AAMSTR is closed */ return /*@ B_READ_MSTR */ /* A successful TBGET of AAMSTR has set (or reset) all the AA~ variables that are needed for the TBCREATE. . ----------------------------------------------------------------- */ C_BUILD: /*@ */ if branch then call BRANCH address ISPEXEC parse value tblnm aatblnm with tblnm . if sw.0describe then do queue "KEYS("aakeys") NAMES("aanames") SORT("aasort")" return end else, if sw.0testmode then do address TSO "CLEAR" say "TBLGEN will issue the following commands:" say "" say, "TBCREATE" tblnm "KEYS("aakeys") NAMES("aanames")" genparms say "" end else do if aalibr = "*" then, if isptabl = "" then do /* wasn't set */ sw.0error_found = 1 zerrsm = "No ISPTABL" zerrlm = "AALIBR was generic and no ISPTABL value was", "provided. Where shall I build this table?" "SETMSG MSG(ISRZ002)" if monitor then say zerrlm return end /* no ISPTABL */ "TBCREATE" tblnm "KEYS("aakeys") NAMES("aanames")" genparms end if rc > 4 then do zerrsm = "TBCREATE failed." if Symbol('zerrlm') = "LIT" then, zerrlm = "No additional diagnostics produced. RC was" rc zerrlm = exec_name "("BRANCH("ID")")", zerrlm "SETMSG MSG(ISRZ002)" if monitor then say zerrlm sw.0error_found = "1"; return end ; else, if rc > 0 then do zerrsm = "Table was replaced." zerrlm = exec_name "("BRANCH("ID")")", "TBCREATE replaced existing table" aatblnm"." "SETMSG MSG(ISRZ002)" if monitor then say zerrlm end if aasort <> "" then do if sw.0testmode then do say "" say, "TBSORT" tblnm "FIELDS("aasort")" say "" end else, "TBSORT" tblnm "FIELDS("aasort")" end return /*@ C_BUILD */ /* . ----------------------------------------------------------------- */ LOCAL_PREINIT: /*@ customize opts */ address TSO source = DFLTTLIB() /* the REAL table lives here */ parse value KEYWD("ISPTLIB") source with, /* AAMSTR location */ isptlib . parse value KEYWD("ISPTABL") with, /* target location */ isptabl . parse value KEYWD("USETBL") "AAMSTR" with, /* the Master Table */ $aa$ . return /*@ LOCAL_PREINIT */ /* . ----------------------------------------------------------------- */ Z_QUEUE: /*@ */ if branch then call BRANCH address TSO return /*@ Z_QUEUE */ /* . ----------------------------------------------------------------- */ HELP: /*@ */ address TSO;"CLEAR" if helpmsg <> "" then do ; say helpmsg; end say " " ex_nam = Left(exec_name,8) /* predictable size */ say " "ex_nam" builds a new ISPF table from parameters stored in the " say " Table Master table. " say " " say " Syntax: "ex_nam" (Required) " say " " say " " say " (Defaults) " say " " say " (( " say " " say " " say " " say " is the two-character identifier which is the key " say " of AAMSTR. " say " " say " instructs" exec_name "to display the commands which " say " would have been issued in the absence of 'TEST'. " say " " say " instructs" exec_name "to return, via the data " say " stack, a description of the table. The following " say " line is placed on the stack: " say " KEYS(...) NAMES(...) SORT(...) " "NEWSTACK"; pull ; "CLEAR" ; "DELSTACK" say " " say " is the name to be given to the newly-created " say " table. If is not specified, the " say " default name stored in the master table, if any, is " say " used. " say " " say " is the name of the table library which contains " say " the master-table. If no value is specified, " say " DFLTTLIB will be called to supply a value. " say " " say " is the name of the table library used for " say " storing the newly-created table. If not specified, " say " the value of AALIBR is used. " say " " say " is the name of the table from which to obtain " say " the definition used to build the new table. If not " say " specified, 'AAMSTR' will be used. " "NEWSTACK"; pull ; "CLEAR" ; "DELSTACK" say " Debugging tools provided include: " say " " say " NOUPDT: by-pass all update logic. " say " " say " BRANCH: show all paragraph entries. " say " " say " TRACE tv: will use value following TRACE to place the execution in" say " REXX TRACE Mode. " say " " say " " say " Debugging tools can be accessed in the following manner: " say " " say " TSO" exec_name" parameters (( debug-options " say " " say " For example: " say " " say " TSO" exec_name " (( MONITOR TRACE ?R " if sw.inispf 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 "QSTACK" /* how many stacks? */ stk2dump = rc - tk_init_stacks /* remaining stacks */ if stk2dump = 0 & queued() = 0 then return 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. */ say "Processing Stack #" dd " Total Lines:" queued() do queued();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 /* except 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")" if wordpos(dlm,back) = 0 then /* search for ending delimiter*/ helpmsg = helpmsg "No matching second delimiter("dlm") with KEYPHRS("kp")" 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 */ 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 . sw.nested = sysvar("SYSNEST") = "YES" sw.batch = sysvar("SYSENV") = "BACK" sw.inispf = sysvar("SYSISPF") = "ACTIVE" parse value KEYWD("TRACE") "O" 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 */