Slide 34 of 80
Notes:
The where script combines many CI programming ideas: multiple entry points are used with input redirection, two forms of file I/O are used, several newer CI function are called, output is aligned in columns, and several more complex CI expressions are encountered. Plus, this script has proven valuable to me and others in CSY numerous times. The next few slide notes will go over some of the more salient points of the where script.
where can be found on Jazz at: http://jazz.external.hp.com/src/scripts/where.txt
- the PARM line allows the “cmd” argument to default to “”, in which case a usage statement is displayed. The by-convention “entry=main” argument is used to handle alternate entry points, with the default entry being named “main”. The user of where will never specify this parameter.
- the ERRCLEAR command is invoked to set CIERROR, HPCIERROR, FSERROR, and HPCIERRCOL predefined variables to 0.
- the delimpos() function is invoked several times and is better than using pos() when two or more characters are being checked. For instance, it is more efficient to code: if delimpos(var,”abc”) > 0 which tests if an “a” or “b” or “c” appears in var, than to code: if pos(“a”,var) > 0 or pos(“b”,var) > 0 or pos(“c”,var) > 0
- intentionally, there are separate tests to see if the “cmd” parameter could potentially be a UDC and/or a MPE named file. Currently, these tests are identical; however, over time the rules may change and this script will be easier to maintain in that event.
- all values of “cmd”, at this point, are assumed to be a legal POSIX filename. Later, the fsyntax() function will be called to ensure that “cmd” is a legal filename.