/* REXX PRINTME ...to the default printer. Execution of PRINTME is dependent upon having an appropriate verb defined in the user command table. The 'action' must be: SELECT CMD(%PRINTME &ZDSN &ZMEM &ZMEMB &ZPARM) |**-***-***-***-***-***-***-***-***-***-***-***-***-***-***-***-**| | | | WARNING: EMBEDDED COMPONENTS. | | See text following TOOLKIT_INIT | | | |**-***-***-***-***-***-***-***-***-***-***-***-***-***-***-***-**| WHY PRINTME CAN'T BE A MACRO: PRINTME can't be a MACRO because it has to be callable from BROWSE and MACROs can't be invoked from BROWSE. Written by Frank Clarke in the Dark Ages Impact Analysis . SYSPROC FCCMDUPD . SYSPROC PRTMODE . SYSPROC TRAPOUT Modification History 20010724 fxc REXXSKEL; WIDEHELP; variable dlm; improved HELP; 20011030 fxc auto-INSTALL; 20020506 fxc FCCMDUPD; no print if SETUP; message if printed; 20030422 fxc recognize the absence of parameters; 20030918 fxc allow override of DEST; 20040701 fxc monitor with SYSUMON; 20050518 fxc catch "argline is empty"; 20050809 fxc snip INSTALL panels; 20061026 fxc truncate at 85 when 'portrait'; */ arg argline if argline = "" then do /* no command table? */ address TSO parse source . . exec_nm . "CLEAR" say say exec_nm "cannot proceed because there is no data to process." say say "You may not have a command-table entry with the proper" say "configuration, or you may not have loaded your command table." say say "If you have a command table and it has been loaded, you should" say "install" exec_nm "by issuing the following command inside ISPF:" say say " ===> tso" exec_nm "(( install " say say "then immediately reload your command table." say say exec_nm "can only be exercised via a command-table entry. If " say "you do not have a command table, you cannot run this routine. " "NEWSTACK";pull;"DELSTACK" "CLEAR" exit end /* REXX SRC */ address TSO /* REXXSKEL ver.20010524 */ arg parms "((" opts signal on syntax signal on novalue call TOOLKIT_INIT /* conventional start-up -*/ rc = trace(tv) info = parms /* to enable parsing */ parse value Left(info,1) '4f'x with dlm . parse var info (dlm) zdsn . (dlm) zmem . (dlm) zmemb . , (dlm) . (dlm) parms if Word(parms,1) = "?" then call HELP /* ...and don't come back */ if sw.0install then do queue "PRINTME" queue 0 queue "SELECT CMD(%PRINTME {&ZDSN {&ZMEM {&ZMEMB { {&ZPARM )" queue "Print the current dataset" "FCCMDUPD" /* write to the command table */ return /* no processing */ end /* */ if sw.0setup then return call A_INIT /* -*/ if \sw.0error_found then, call B_PRINT /* -*/ exit /*@ PRINTME */ /* . ----------------------------------------------------------------- */ A_INIT: /*@ */ address TSO if zdsn = "" then do /* primary parameter missing */ sw.0error_found = 1 zerrsm = exec_name "inoperable" zerrlm = "The parameter string was empty at program-start. ", exec_name "was called incorrectly. You may be ", "running in an unsupported environment." address ISPEXEC "SETMSG MSG(ISRZ002)" return end parse var zdsn ebdsn . /* strip */ parse value zmem zmemb with ebmem . ldrc = Listdsi("'"zdsn"' DIRECTORY NORECALL") if Left(sysdsorg,2) = "PO" then, ebdsn = ebdsn"("ebmem")" info = parms /* setup for parsing */ sw.0land = SWITCH("LAND") sw.0port = SWITCH("PORT") forcedest = KEYWD("ON") /* temporary destination */ if sw.0land + sw.0port <> 1 then, parse value "0 1" with, sw.0land sw.0port . if sw.0land then prtdest = "DEST("prtdestl")" else prtdest = "DEST("prtdestp")" if forcedest <> "" then, prtdest = "DEST("forcedest")" monparm = "/USER" Userid() "TOOL" exec_name if tv = "O" then, "CALL 'NTIN.TS.D822.LIB.ISPLLIB(SYSPMON)'" "'" monparm"'" return /*@ A_INIT */ /* . ----------------------------------------------------------------- */ B_PRINT: /*@ */ address TSO if sw.0port then info = info "TRUNCATE(85)" "PRINTDS DATASET('"ebdsn"') CLASS("prtcls")" prtdest info zerrhm = "ISR00000" zerrsm = "Printed" /* short message */ zerrlm = ebdsn "was printed CLASS("prtcls") DEST("prtdest")" zerralrm = "YES" /* beep the screen */ address ISPEXEC "SETMSG MSG(ISRZ002)" return /*@ B_PRINT */ /* . ----------------------------------------------------------------- */ LOCAL_PREINIT: /*@ customize opts */ address ISPEXEC sw.0install = SWITCH("INSTALL") sw.0setup = SWITCH("SETUP") "VGET (PRTCLS PRTDESTP PRTDESTL) PROFILE" if Words(prtcls prtdestp prtdestl) <> 3 |, sw.0setup then do /* get new parms */ call DEIMBED /* extract panels -*/ call ZA_PROLOG /* LIBDEF establish -*/ call ZG_GETVALS /* prompt for values -*/ call ZZ_EPILOG /* LIBDEF drop -*/ end /* get new parms */ return /*@ LOCAL_PREINIT */ /* subroutines below LOCAL_PREINIT are not selected by SHOWFLOW */ /* . ----------------------------------------------------------------- */ ZA_PROLOG: /*@ */ if branch then call BRANCH address ISPEXEC dd = "" do Words(ddnlist) /* each LIBDEF DD */ parse value ddnlist dd with dd ddnlist $ddn = $ddn.dd /* PLIB322 <- PLIB */ "LIBDEF ISP"dd "LIBRARY ID("$ddn") STACK" end ddnlist = ddnlist dd return /*@ ZA_PROLOG */ /* Get PRTCLS and PRTDEST. Write them to the profile. . ----------------------------------------------------------------- */ ZG_GETVALS: /*@ */ if branch then call BRANCH address ISPEXEC "VGET ZPFCTL"; save_zpf = zpfctl /* save current setting */ zpfctl = "OFF"; "VPUT ZPFCTL" /* PFSHOW OFF */ "ADDPOP ROW(8) COLUMN(5)" zwinttl = "Verify Printer Parameters" "DISPLAY PANEL(PRTVALS)" disp_rc = rc "REMPOP ALL" zpfctl = save_zpf; "VPUT ZPFCTL" /* restore */ "VPUT (PRTCLS PRTDESTP PRTDESTL) PROFILE" return /*@ ZG_GETVALS */ /* . ----------------------------------------------------------------- */ ZZ_EPILOG: /*@ */ if branch then call BRANCH address ISPEXEC dd = "" do Words(ddnlist) /* each LIBDEF DD */ parse value ddnlist dd with dd ddnlist $ddn = $ddn.dd /* PLIB322 <- PLIB */ "LIBDEF ISP"dd address TSO "FREE FI("$ddn")" end ddnlist = ddnlist dd return /*@ ZZ_EPILOG */ /* Parse out the embedded components at the back of the source code. . ----------------------------------------------------------------- */ DEIMBED: Procedure expose, /*@ */ (tk_globalvars) ddnlist $ddn. daid. address TSO fb80po.0 = "NEW UNIT(VIO) SPACE(5 5) TRACKS DIR(40)", "RECFM(F B) LRECL(80) BLKSIZE(0)" parse value "" with ddnlist $ddn. daid. lastln = sourceline() currln = lastln /* */ if Left(sourceline(currln),2) <> "*/" then return currln = currln - 1 /* previous line */ "NEWSTACK" address ISPEXEC do while sourceline(currln) <> "/*" text = sourceline(currln) /* save with a short name ! */ if Left(text,3) = ")))" then do /* package the queue */ parse var text ")))" ddn mbr . /* PLIB PANL001 maybe */ if Pos(ddn,ddnlist) = 0 then do /* doesn't exist */ ddnlist = ddnlist ddn /* keep track */ $ddn = ddn || Random(999) $ddn.ddn = $ddn address TSO "ALLOC FI("$ddn")" fb80po.0 "LMINIT DATAID(DAID) DDNAME("$ddn")" daid.ddn = daid end daid = daid.ddn "LMOPEN DATAID("daid") OPTION(OUTPUT)" do queued() parse pull line "LMPUT DATAID("daid") MODE(INVAR) DATALOC(LINE) DATALEN(80)" end "LMMADD DATAID("daid") MEMBER("mbr")" "LMCLOSE DATAID("daid")" end /* package the queue */ else push text /* onto the top of the stack */ currln = currln - 1 /* previous line */ end /* while */ address TSO "DELSTACK" return /*@ DEIMBED */ /* . ----------------------------------------------------------------- */ HELP: /*@ */ address TSO;"CLEAR" ; say "" if helpmsg <> "" then do ; say helpmsg; say ""; end ex_nam = Left(exec_name,8) /* predictable size */ say " "ex_nam" prints the dataset currently being browsed or edited. The" say " CLASS and DEST for the printer is stored in the profile. " say " If the appropriate variables are not found in the profile " say " you will be prompted to supply them. " say " " say " Syntax: "ex_nam" " say " " say " " say " (( " say " " say " " say " PORT/LAND specifies the required orientation (portrait or " say " landscape). If neither/both are specified, the " say " default is 'PORT'. " say " " say " unumber specifies a printer destination to be used for this " say " print task only. It is not retained. " "NEWSTACK"; pull ; "CLEAR" ; "DELSTACK " say " " say " The following tokens must be specified after a double " say " open-parenthesis. " say " " say " SETUP requests the setup dialog be started in order to " say " verify/change the printer parameters. " say " " say " INSTALL causes a command to be inserted to the user's " say " command table to enable this routine to be called " say " from the command line. " say " " say " If INSTALL or SETUP, no printing is done. " say " " "NEWSTACK"; pull ; "CLEAR" ; "DELSTACK " say " Debugging tools provided include: " say " " say " MONITOR: displays key information throughout processing. " 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 "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 = "exec_name tv helpmsg sw. zerrhm zerralrm ", "zerrsm zerrlm tk_init_stacks branch monitor ", "noupdt" call LOCAL_PREINIT /* for more opts -*/ return /*@ TOOLKIT_INIT */ /* )))PLIB PRTVALS )ATTR % TYPE(TEXT) INTENS(HIGH) SKIP(ON) + TYPE(TEXT) INTENS(LOW) SKIP(ON) _ TYPE(INPUT) INTENS(HIGH) CAPS(ON) JUST(LEFT) PAD('_') @ TYPE(OUTPUT) INTENS(HIGH) CAPS(ON) JUST(LEFT) $ TYPE(INPUT) INTENS(HIGH) CAPS(ON) JUST(LEFT) )BODY WINDOW(68,5) + + Print CLASS%==>$z+ + Print DEST%==>$z + (Portrait) + Print DEST%==>$z + (Landscape) + )INIT .ZVARS = '(PRTCLS PRTDESTP PRTDESTL)' .HELP = PRTVALH .CURSOR = PRTCLS )PROC VER (&PRTCLS,NB) VER (&PRTDESTP,NB) VER (&PRTDESTL,NB) )END )))PLIB PRTVALH )ATTR % TYPE(TEXT) INTENS(HIGH) SKIP(ON) + TYPE(TEXT) INTENS(LOW) SKIP(ON) _ TYPE(INPUT) INTENS(HIGH) ! TYPE(OUTPUT) INTENS(HIGH) SKIP(ON) @ TYPE(OUTPUT) INTENS(LOW) SKIP(ON) )BODY EXPAND() %TUTORIAL - Verify Printer Parameters - TUTORIAL %Next Selection ===>_ZCMD + + Enter the one-character class value associated with your preferred + printer. Usually '6' + + Enter the destination-strings for 'Portrait' orientation and 'Landscape' + orientation associated with your preferred printer. Usually 'U##' + )PROC )END */