/* REXX TIMEMATH From time specified as hh:mm:ss or mm:ss, compute 1%, 5%, 10%, 20%, 25% 30%, 33%, 40%, 50%, 60%, 67%, 70%, 75%, 80%, and 90%. Use '(routine name) ?' for HELP-text. |**-***-***-***-***-***-***-***-***-***-***-***-***-***-***-***-**| | | | WARNING: EMBEDDED COMPONENTS. | | See text following TOOLKIT_INIT | | | |**-***-***-***-***-***-***-***-***-***-***-***-***-***-***-***-**| Written by Frank Clarke rexxhead@yahoo.com 20211005 Impact Analysis . SYSEXEC TRAPOUT Modification History 20230726 fxc adjust HELP; 20230806 fxc chg SYSPROC to SYSEXEC in Impact Analysis; 20230911 fxc use ZUP/ZCONT in HELP panels; 20240305 fxc align panel names; 20240308 fxc chg dollar-sign to @ everywhere; 20240415 fxc DUMP_QUEUE quiet; */ arg argline address TSO /* REXXSKEL ver.20210402 */ 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 /* Initialization -*/ call M_MAIN_PROCESS /* Working section -*/ if \sw.nested then call DUMP_QUEUE 'quiet' /* -*/ exit /*@ TIMEMATH */ /* Initialization . ----------------------------------------------------------------- */ A_INIT: /*@ */ if branch then call BRANCH address TSO parse value "" with, intime holdtime tm01 tm05 tm10 tm20 tm25 tm30 tm33 tm40, tm50 tm60 tm67 tm70 tm75 tm80 tm90 secs hhmmss return /*@ A_INIT */ /* Working section . ----------------------------------------------------------------- */ M_MAIN_PROCESS: /*@ */ if branch then call BRANCH address TSO call MA_PROLOG /* -*/ call MD_DISPLAY /* -*/ call MZ_EPILOG /* -*/ return /*@ M_MAIN_PROCESS */ /* Extract and activate ISPF assets . ----------------------------------------------------------------- */ MA_PROLOG: /*@ */ if branch then call BRANCH address ISPEXEC call DEIMBED /* */ 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 /*@ MA_PROLOG */ /* Display main panel. Compute time fragments. . ----------------------------------------------------------------- */ MD_DISPLAY: /*@ */ if branch then call BRANCH address ISPEXEC do forever "DISPLAY PANEL(TMMAIN)" if rc = 8 then leave /* PF3 ? */ if intime = '' then leave /* no input */ parse var intime ta ":" tb ":" tc . parse value "0 0 0 0 0" with, hh mm ss . parse value intime with, holdtime . . . . . intime . if Words(ta tb tc) = 2 then , parse value ta tb with, mm ss . else, if Words(ta tb tc) = 3 then , parse value ta tb tc with, hh mm ss . else do zerrsm = "Too small" zerrlm = "You entered" holdtime".", "Not set up to compute values for < 1 minute." "SETMSG MSG(ISRZ002)" iterate end /* hh mm and ss are set */ secs = ss + mm*60 + hh*3600 tm01 = Z_SECS_TO_HMS( secs/100 ) /* -*/ tm05 = Z_SECS_TO_HMS( secs/20 ) /* -*/ tm10 = Z_SECS_TO_HMS( secs/10 ) /* -*/ tm20 = Z_SECS_TO_HMS( 2*secs/10 ) /* -*/ tm25 = Z_SECS_TO_HMS( secs/4 ) /* -*/ tm30 = Z_SECS_TO_HMS( 3*secs/10 ) /* -*/ tm33 = Z_SECS_TO_HMS( secs/3 ) /* -*/ tm40 = Z_SECS_TO_HMS( 4*secs/10 ) /* -*/ tm50 = Z_SECS_TO_HMS( 5*secs/10 ) /* -*/ tm60 = Z_SECS_TO_HMS( 6*secs/10 ) /* -*/ tm67 = Z_SECS_TO_HMS( 2*secs/3 ) /* -*/ tm70 = Z_SECS_TO_HMS( 7*secs/10 ) /* -*/ tm75 = Z_SECS_TO_HMS( 3*secs/4 ) /* -*/ tm80 = Z_SECS_TO_HMS( 8*secs/10 ) /* -*/ tm90 = Z_SECS_TO_HMS( 9*secs/10 ) /* -*/ end /* forever */ return /*@ MD_DISPLAY */ /* Deactivate ISPF assets . ----------------------------------------------------------------- */ MZ_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 /*@ MZ_EPILOG */ /* Receive ssss seconds and convert to hh:mm:ss . ----------------------------------------------------------------- */ Z_SECS_TO_HMS: /*@ */ if branch then call BRANCH address TSO parse arg ssss ssss = Format( ssss,9,0 ) /* round up or down */ zss = ssss // 60 /* seconds */ ssss = ssss % 60 zmm = ssss // 60 /* minutes */ zhh = ssss % 60 /* hours */ hhmmss = Right( zhh,2,0 )":"Right( zmm,2,0 )":"Right( zss,2,0 ) return( hhmmss ) /*@ Z_SECS_TO_HMS */ /* . ----------------------------------------------------------------- */ LOCAL_PREINIT: /*@ customize opts */ address TSO return /*@ LOCAL_PREINIT */ /* subroutines below LOCAL_PREINIT are not selected by SHOWFLOW */ /* Parse out the embedded components at the back of the source code. The components are enclosed in a comment whose start and end are on individual lines for easier recognition. Each component is identified by a triple-close-paren ")))" in column 1 followed by a DDName and a membername. The text of the component begins on the next line. There are no restrictions on the DDName, but ISPF assets are treated differently than non-ISPF material. Items to be LIBDEFd should be held to 4 character DDNs to accomodate the 'ISP' that will be prepended. Code is supplied below to properly LIBDEF ISPF elements. Non-ISPF elements are not LIBDEFd but EXECIOd to a PO/80 dataset named for the DDN specified. . ----------------------------------------------------------------- */ DEIMBED: Procedure expose, /*@ */ (tk_globalvars) ddnlist @ddn. daid. address TSO fb80po.0 = "NEW REU UNIT(SYSDA) SPACE(1 5) TRACKS DIR(40)", "RECFM(F B) LRECL(80) BLKSIZE(0)" fb80po.1 = "SHR REU" 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 length(ddn) > 4 then do /* data, not ISPF */ call DESPOOL /* -*/ currln = currln - 1 /* previous line */ iterate end if Pos(ddn,ddnlist) = 0 then do /* doesn't exist */ ddnlist = ddnlist ddn /* keep track */ @ddn = ddn || Random(999) /* PLIB322 maybe */ @ddn.ddn = @ddn /* @ddn.PLIB = PLIB322 */ 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 /* Subroutine of DEIMBED for non-ISPF data. Given: the stack, ddn, and mbr . ----------------------------------------------------------------- */ DESPOOL: /*@ */ if branch then call BRANCH address TSO if Sysdsn(ddn".DATA") <> "OK" then, "ALLOC FI("ddn") DA("ddn".DATA)" fb80po.0 "ALLOC FI("ddn") DA("ddn".DATA("mbr")) SHR REU" "EXECIO" queued() "DISKW" ddn "(FINIS" "DELSTACK" "NEWSTACK" /* re-establish */ return /*@ DESPOOL */ return /*@ DEIMBED */ /* . ----------------------------------------------------------------- */ HELP: /*@ */ address TSO;"CLEAR" if helpmsg <> "" then say helpmsg ex_nam = Left(exec_name,8) /* predictable size */ say " " say " "ex_nam" computes percentages of a time specified as hh:mm:ss or " say " mm:ss " say " " say " Syntax: "ex_nam" no parms " 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 " 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 " 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 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 /* 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")", 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.nested = sysvar("SYSNEST") = "YES" sw.batch = sysvar("SYSENV") = "BACK" sw.inispf = 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 */ /* ))) PLIB TMMAIN .. )ATTR DEFAULT([+{) [ TYPE( TEXT ) INTENS( HIGH ) SKIP( ON ) + TYPE( TEXT ) INTENS( LOW ) SKIP( ON ) _ TYPE( INPUT ) INTENS( LOW ) CAPS( ON ) @ TYPE( TEXT ) INTENS( HIGH ) COLOR( YELLOW ) ! TYPE( OUTPUT ) INTENS( LOW ) COLOR( YELLOW ) )BODY EXPAND(||) WIDTH(&ZSCREENW) @|-|[ Compute Time Fragments @|-| [COMMAND ===>_ZCMD [SCROLL ===>_ZAMT+ + + Enter Time ==>_intime + !holdtime + Seconds:!secs + [ 1% !TM01 [ 5% !TM05 [ 10% !TM10 + [ 20% !TM20 [ 25% !TM25 + [ 30% !TM30 [ 33% !TM33 + [ 40% !TM40 [ + [ 50% !TM50 [ + [ 60% !TM60 [ 67% !TM67 + [ 70% !TM70 [ 75% !TM75 + [ 80% !TM80 [ + [ 90% !TM90 [ + )INIT .HELP = TMMAINH )PROC )END ))) PLIB TMMAINH .. )ATTR DEFAULT([+{) [ 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(||) WIDTH(&ZSCREENW) [TUTORIAL |-| Compute Time Fragments |-| TUTORIAL [Next Selection ===>_ZCMD + + + Enter a time value as[hh:mm:ss+or[mm:ss+and press[ENTER. + + + The process will return the hh:mm:ss values for[1%, 5%, 10%, 20%, 25%, 30%, [ 33%, 40%, 50%, 60%, 67%, 70%, 80%,+and[90%+of the original. + + [PF3+or[ENTER+without an input value to end. )PROC &ZCONT = TMMAINH &ZUP = TMMAINH )END */