/* REXX PDS2SEQ Convert a PDS to a sequential dataset either for printing or for edit/IEBUPDTE restore. Written by Frank Clarke in the Dark Ages Rebuilt by Frank Clarke, Richmond, 19991230 Impact Analysis . SYSPROC MEMBERS . SYSPROC TRAPOUT Modification History ccyymmdd xxx ..... .... */ arg argline address TSO /* REXXSKEL ver.19991109 */ arg parms "((" opts signal on syntax signal on novalue call TOOLKIT_INIT /* conventional start-up -*/ rc = trace(tv) info = parms /* to enable parsing */ call A_INIT /* -*/ if sw.0error_found then nop ; else , call B_TRANSFER /* -*/ if \sw.nested then call DUMP_QUEUE /* -*/ exit /*@ PDS2SEQ */ /* . ----------------------------------------------------------------- */ A_INIT: /*@ */ if branch then call BRANCH address TSO call AA_KEYWDS /* -*/ parse var info dsname info if dsname = "" then, helpmsg = helpmsg " Input DSName was not specified." if info <> "" then, helpmsg = helpmsg " Unrecognized parameters: >"info"<" if helpmsg <> "" Then call HELP /* ...and don't come back */ if Left(dsname,1) = "'" then, dsname = Strip(dsname,,"'") /* unquoted */ else, dsname = Userid()"."dsname /* fully-qualified */ return /*@ A_INIT */ /* . ----------------------------------------------------------------- */ AA_KEYWDS: /*@ */ if branch then call BRANCH address TSO parse value KEYWD("OUTPUT") "PDS2SEQ.DATA" with, outdsn . parse value KEYWD("FOR") "EDIT" with, purpose . fmbr = KEYWD("FROM") tmbr = KEYWD("TO") fmbrl = Max(Length(fmbr),1) tmbrl = Max(Length(tmbr),1) return /*@ AA_KEYWDS */ /* All the tasks associated with making the 'input' output. . ----------------------------------------------------------------- */ B_TRANSFER: /*@ */ if branch then call BRANCH address TSO call BA_GET_MEMBERS /* -*/ if sw.0error_found then return call BB_ALLOC_OUTPUT /* -*/ if sw.0error_found then return do Words(mbrlist) /* every member */ parse var mbrlist mbr mbrlist /* isolate */ if CERTIFY(mbr) then do /* transfer text */ if monitor then say, "Selected" mbr "NEWSTACK" call BC_EXECIO /* -*/ "DELSTACK" end /* CERTIFY */ else, /* rejected */ if monitor then say, "Rejected" mbr end /* words(mbrlist) */ "EXECIO 0 DISKW OUT (FINIS" /* close output */ "FREE FI($IN OUT)" return /*@ B_TRANSFER */ /* Obtain a list of members. . ----------------------------------------------------------------- */ BA_GET_MEMBERS: /*@ */ if branch then call BRANCH address TSO "NEWSTACK" "MEMBERS" "'"dsname"'" "((STACK LINE" pull mbrlist "DELSTACK" return /*@ BA_GET_MEMBERS */ /* Prepare the output dataset. . ----------------------------------------------------------------- */ BB_ALLOC_OUTPUT: /*@ */ if branch then call BRANCH address TSO ldrc = Listdsi("'"dsname"' directory norecall") parse var sysrecfm form 2 if purpose = "PRINT" then, recfm = form "B A" else recfm = form "B" msgstat = Msg("OFF") "FREE FI(OUT)" ; "DELETE" outdsn rc = Msg(msgstat) /* restore */ if sysunits = "BLOCK" then sysunits = "TRACKS" "ALLOC FI(OUT) DA("outdsn") NEW CATALOG REU UNIT(SYSDA)", sysunits "SPACE("sysused sysseconds") BLKSIZE(0)", "RECFM("recfm") LRECL("syslrecl")" return /*@ BB_ALLOC_OUTPUT */ /* Get input data; modify as necessary; add header info; write. . ----------------------------------------------------------------- */ BC_EXECIO: /*@ */ if branch then call BRANCH address TSO if noupdt then return /* don't read or write */ "ALLOC FI($IN) DA('"dsname"("mbr")') SHR REU" "EXECIO * DISKR $IN (FINIS" if purpose = "EDIT" then do push "./ REPL NAME="mbr /* IEBUPDTE header */ end /* EDIT */ else do /* PRINT */ do queued() parse pull line; queue " "line end push " "; push "1" dsname"("mbr")" end /* PRINT */ "EXECIO" queued() "DISKW OUT" /* not FINIS... */ return /*@ BC_EXECIO */ /* Is this member one we should process? . ----------------------------------------------------------------- */ CERTIFY: Procedure expose, /*@ */ (tk_globalvars) fmbr tmbr fmbrl tmbrl mbr if branch then call BRANCH address TSO valid = "1" if fmbr <> "" then, if fmbr > Left(mbr,fmbrl) then valid = "0" if tmbr <> "" then, if tmbr < Left(mbr,tmbrl) then valid = "0" return(valid) /*@ CERTIFY */ /* . ----------------------------------------------------------------- */ LOCAL_PREINIT: /*@ customize opts */ address TSO return /*@ LOCAL_PREINIT */ /* . ----------------------------------------------------------------- */ HELP: /*@ */ address TSO;"CLEAR" if helpmsg <> "" then do ; say helpmsg; say ""; end ex_nam = Left(exec_name,8) /* predictable size */ say " "ex_nam" Convert a PO dataset to PS for printing or batch " say " update. " say " " say " Syntax: "ex_nam" (Required)" say " (Defaults)" say " (Defaults)" say " " say " " say " " say " identifies the PO dataset which is to be " say " converted. " say " " say " identifies the output dataset. " say " " say " may be either 'EDIT' or 'PRINT'. If not " say " specified, the default is 'EDIT'. " say " " say " more...... " pull "CLEAR" say " " say " if specified, identifies the first member to" say " be written to the output. may be a" say " partial membername. If, for instance, " say " is 'BT' the first member whose name" say " begins with 'BT' will be selected even if " say " the membername is longer. Prior members " say " will not be selected. " say " " say " If is not specified, selection " say " begins with the first member. " say " " say " if specified, identifies the last member to " say " be written to the output. may be a" say " partial membername. If, for instance, " say " is 'TB' the last member whose name " say " begins with 'TB' will be selected even if " say " the membername is longer. Later members " say " will not be selected. " say " " say " If is not specified, selection ends" say " with the last member. " pull "CLEAR" say " Debugging tools provided include: " say " " say " MONITOR: displays key information throughout processing. " say " Displays most paragraph names upon entry. " 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 " say " execution in 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" (( MONITOR TRACE ?R " 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 */ "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 */ /* . ----------------------------------------------------------------- */ 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+1) /* 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 sourceline(ssii) ; 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 = "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 */