/* REXX FIRSTIME Do a process if for the first time . Written by Frank Clarke, Oldsmar, FL Impact Analysis . SYSPROC FTINIT Modification History 19950221 fxc "THIS WEEK" doesn't work because 'this' was in lower case and was being compared against upper case text 19950329 fxc failed on "this wednesday" because no check was being done other than 'is today the right day?'; any other day produced HELP text 19960612 fxc squeeze space out of line before rewriting; lack of this caused an odd failure in which the data continually got longer with each iteration until it was lost off the end of the file; upgrade to REXXSKEL; 19970212 fxc recognize NOUPD and NOUPDT as being equivalent; upgrade from v.960606 to v.970113; 19980604 fxc upgrade from v.970113 to v.19980225; RXSKLY2K; DECOMM; standardize; 19991103 fxc drop support for NOUPD 20010601 fxc HELP was doing a RETURN instead of an EXIT */ address TSO /* 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 */ call A_INIT /* -*/ call B_GET_FTC /* -*/ call C_CHECK_FTC /* -*/ call D_WRITE_FTC /* -*/ if \sw.nested then call DUMP_QUEUE /* -*/ exit /*@ FIRSTIME */ /* . ----------------------------------------------------------------- */ A_INIT: /*@ */ if branch then call BRANCH address TSO run = "0" /* off by default */ weekdays = "SUNDAY MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY" "NEWSTACK" call FTINIT /* -*/ pull ftc "DELSTACK" parse upper value Date("B") Date("S") Date("W") with, daily sdate dayname . day_idx = daily//7 weekly = daily - day_idx /* start of the week */ monthly = Left(sdate,6) /* current month - YYYYMM */ annual = Left(sdate,4) /* current year - YYYY */ /* parse parms */ parse var parms token1 rest if token1 = "THIS" then, /* token-1 may be "this" */ parse var rest token1 rest /* 1st rem token is t-scale */ return /*@ A_INIT */ /* Read the user's personal FTC file (contains info about when this routine was last run). . ----------------------------------------------------------------- */ B_GET_FTC: /*@ */ if branch then call BRANCH address TSO "NEWSTACK" /* fence off a buffer */ ftcalc.0 = "NEW CATALOG UNIT(SYSDA) SPACE(1) TRACKS", "RECFM(V B) LRECL(255) BLKSIZE(0)" ftcalc.1 = "SHR" /* if it already exists... */ tempstat = Sysdsn(ftc) = "OK" /* 1=exists, 0=missing */ "ALLOC FI($TMP) DA("ftc") REU" ftcalc.tempstat "ALLOC FI(CTL) DA("ftc") SHR REU" "FREE FI($TMP)" if tempstat = 0 then do call BA_GENLINE /* establish line -*/ end else do "EXECIO 1 DISKR CTL (FINIS" pull line line = Space(line,1) /* condense */ end "DELSTACK" /* purge the buffer */ if monitor then say "Contents of" ftc":" line return /*@ B_GET_FTC */ /* FTC was non-existent; build a new one. . ----------------------------------------------------------------- */ BA_GENLINE: /*@ */ if branch then call BRANCH address TSO line = "D:"0 "W:"0 "M:"0 "A:"0 "D0:"0 , "D1:"0 "D2:"0 "D3:"0 "D4:"0 "D5:"0 "D6:"0 push line "EXECIO 1 DISKW CTL (FINIS" return /*@ BA_GENLINE */ /* . ----------------------------------------------------------------- */ C_CHECK_FTC: /*@ */ if branch then call BRANCH address TSO select /* what kind of check ? */ when token1 = "TODAY" |, token1 = "DAY" |, token1 = "DAILY" then do parse var line front "D:" last_x back if last_x < daily then do line = front "D:"daily back run="1" end end /* Daily */ when token1 = "WEEK" |, token1 = "WEEKLY" then do parse var line front "W:" last_x back if last_x < weekly then do line = front "W:"weekly back run="1" end end /* Weekly */ when token1 = "MONTH" |, token1 = "MONTHLY" then do parse var line front "M:" last_x back if last_x < monthly then do line = front "M:"monthly back run="1" end end /* Monthly */ when token1 = "YEAR" |, token1 = "ANNUALLY" |, token1 = "YEARLY" then do parse var line front "A:" last_x back if last_x < annual then do line = front "A:"annual back run="1" end end /* Annually */ when Wordpos(token1,weekdays) > 0 then do if token1 <> dayname then, /* restricted to specific day */ update = "0" /* not the right day... */ else do /* we can run today */ parse var line front "D0:" last.0 "D1:" last.1 "D2:" last.2, "D3:" last.3 "D4:" last.4 "D5:" last.5 "D6:" last.6, back /* Monday=0, Tuesday=1, Sunday=6 */ if last.day_idx < daily then do last.day_idx = daily line = front "D0:"last.0 "D1:"last.1 "D2:"last.2, "D3:"last.3 "D4:"last.4 "D5:"last.5, "D6:"last.6 back run="1" end /* file LT current */ end /* we can run today */ end /* Specific day */ otherwise do "CLEAR" helpmsg = "ERR ===> Cycle indicator '"token1"' not recognized." call HELP update = "0" /* don't write to CTL */ end end /* select */ if run then do /* to run or not to run ? */ if monitor then say "Running command:" rest address TSO rest end else, if monitor then say "Ignoring command:" rest return /*@ C_CHECK_FTC */ /* . ----------------------------------------------------------------- */ D_WRITE_FTC: /*@ */ if branch then call BRANCH address TSO if update then do /* to updt or not to updt ? */ if monitor then, say "Replace FTC with <"line">" line = Space(line,1) push line "EXECIO 1 DISKW CTL (FINIS" end else, if monitor then, say "FTC was not replaced" "FREE FI(CTL)" return /*@ D_WRITE_FTC */ /* . ----------------------------------------------------------------- */ LOCAL_PREINIT: /*@ customize opts */ if branch then call BRANCH address TSO update = \noupdt return /*@ LOCAL_PREINIT */ /* . ------------------------------------------------------------------ */ HELP: /*@ */ address TSO;"CLEAR" if helpmsg <> "" then do ; say helpmsg; say ""; end say " FIRSTIME controls execution of once-per-period events. " say " " say " Syntax: FIRSTIME " say " " say " " say " may be any ONE of the following: , " say " , , , , , " say " , , , , , " say " , , , , . " say " " say " may be any TSO command which the user is " say " authorized to issue. " say " " say " When a day-of-the-week is specified as the cycle-indicator, execution " say " will occur ONLY on that day. " say " " say " (The word 'this' within the cycle-indicator may be left out.) " say " " say " more.... " "NEWSTACK" ; pull ; "CLEAR" ; "DELSTACK" say " " say " NOTE :::: " say " Occasionally it is necessary to run more than one task per " say " time period, for example: several tasks needing to be done " say " each week. The normal mode of operation is to run once per " say " period, so the second call to "exec_name" fails (because it " say " just ran). To run multiple tasks, specify NOUPDT for all but " say " the last: " say " " say " TSO FIRSTIME THIS WEEK PROCA ((NOUPDT " say " TSO FIRSTIME THIS WEEK PROCB ((NOUPDT " say " TSO FIRSTIME THIS WEEK PROCC " say " " say " -- PROCA runs but doesn't update the control file. " say " -- To PROCB, it appears that it is OK to run; it runs but also " say " doesn't update the control file. " say " -- PROCC finds the control file not yet updated, runs, and " say " updates the control file. " say " -- If this series is rerun, the control file will have been " say " updated and it will not run again. " say " " "NEWSTACK" ; pull ; "CLEAR" ; "DELSTACK" 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 execution " say " in 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 " address ISPEXEC "CONTROL DISPLAY REFRESH" exit /*@ HELP */ /* REXXSKEL back-end removed for space */