stream UDC - “read_jobcard”
else # alternate entry points for UDC. setvar _str_entry word("!streamparms",,-1) # remove entry=name from parm line setvar _str_entry_parms lft('!streamparms',pos('entry=','!streamparms')-1) if _str_entry = "read_jobcard" then # Arg 1 is the *name* of the var to hold all of the JOB card right of "JOB". # Input redirected to the target job file being streamed # Read file until JOB card is found. Return, via arg1, this record, # including continuation lines, but less the "JOB" token itself. Remove # all passwords, if any. Skip leading comments in job file. setvar _str_arg1 word(_str_entry_parms) while str(setvar(!_str_arg1,ups(input())),2,4) <> "JOB " do endwhile # remove line numbers, if appropriate if setvar(_str_numbered, numeric(rht(!_str_arg1,8))) then setvar !_str_arg1 lft(!_str_arg1,len(!_str_arg1)-8) endif ...
Notes:
- The next few slides detail the two alternate entry points for the STREAM UDC. If the entry is not “main” then it is an alternate entry. The first step is to determine which entry is being called by extracting the entry name. By convention the entry name is the last parameter passed to the UDC, and thus is extracted via word(…,-1).
- Next, the “entry=name” needs to be removed from the parameter line so that the alternate entry routines can freely parse the arguments.
- Now a test can be made for each individual entry name, and each entry point can be coded like a subroutine. All entries have read and write access to all of the variables set by the UDC.
- The “read_jobcard” entry defines the first parameter (arg1) to be the name of a CI string variable that will contain the full job “card” line minus the pseudo colon and the word “JOB” (“!JOB “).
- Input has been redirected to the stream job file, which the “main” entry verified exists.
- Since there can be comments preceding the JOB command line, these are skipped by the WHILE loop above. This WHILE loop reads the JOB record, via the input() function, and stops.
- A simple test is made to determine if the stream file is numbered or unnumbered: if the last 8 characters of the JOB card record are numeric then the entire file is considered numbered.