Slide 36 of 80
Notes:
- this slide shows the end of the “main” entry code in the where script.
- here is the loop that parses each element in HPPATH, tests to see if a file exists based on the “cmd” value and the extracted element from HPPATH, and invokes an entry “subroutine” to display the filename and other file attributes.
- the word() function extracts a token from HPPATH based on the defined delimiters of a comma, semicolon or a space. The word counter/index (_wh_i) is incremented inside the argument to word(), which is not necessary, but more convenient and slightly more efficient.
- the delimpos() function is used to see if the extracted HPPATH element is an MPE name or a POSIX name. POSIX elements are prepended to the “cmd” value and MPE path elements are appended to “cmd”.
- if the “cmd” value was wildcarded, e.g. “grep@”, then the LISTFILE command lists the full filenames to disk. Otherwise, the non-wildcard name is qualified by calling the fqualify() function, and written to the same output file used by LISTFILE. This allows a single entry routine to do all of the formatted output for a file.
- XEQ and HPFILE are used again to invoke the script recursively, this time passing the “process_listf” entry name, and redirecting input to a file that contains the equivalent of a LISTFILE,6 output.
- regardless of success or failure, all _wh_@ variables are deleted and control returns to the invoker of the script. In this script the two TEMP files are not purged and the file equation, seen later, is not reset. For scripts with more complex cleanup, I often use an alternate entry point specifically for doing all of the cleanup. This entry is invoked in place of executing a simple RETURN.