Piping Info Strings Via Command Files
In our support efforts we get to use the EDITOR and QUERY utilities up ?close and personal?. My favorite EDITOR command script accomplishes the run of EDITOR, the Text(ing) of the file, and setting up the environment, all in one command. The script looks like this, saved as a file named EDIT on your HPPATH.
parm file=""
RUN EDITOR.PUB.SYS;INFO="T !file;SET TIME=1000,NOLNBRK"
Now the command “EDIT XYZFILE” will automatically text in the file XYZFILE. The other advantage of this method is that the command is captured in the history list so that it can be repeated with a “DO E” command. The SET TIME=1000 allows the W(hile) command to execute properly. This method is also of interest to programmers since it suggests that the INFO string can easily be used in place of the more cumbersome accept/display logic for batch job parameter input.
The above works fine for programs that can process the INFO string, but what about ?older? programs that are INFO ignorant? A good example of this type of program is QUERY.PUB.SYS. A very common question is ?How do I automate/prompt for input into these types of programs??. The answer is to build an input script for the program that prompts for the desired input variables. Consider the following example command script:
PURGE QSIN >$NULL
BUILD QSIN;REC=-79,,F,ASCII
FILE QSIN=QSIN,OLD;ACC=APPEND
INPUT SVAL;PROMPT="SEARCH VALUE (????)>"
SETVAR FIND,"F ITEM IS "+STR(SVAL,1,4)
ECHO B=DB>*QSIN
ECHO PASSWORD>*QSIN
ECHO 5>*QSIN
ECHO !FIND>*QSIN
ECHO R ALL>*QSIN
ECHO EXIT>*QSIN
FILE QSIN=QSIN,OLD;DEV=DISC
RUN QUERY.PUB.SYS <QSIN
The above script builds the input file to drive QUERY. Note the use of the piping directives. The “>” causes output to the file or program and the “<” causes input from the file. The ?tricks? used here are that the input file QSIN is set for APPEND access and then reset prior to piping it into QUERY. The other trick is to prompt for the input data then glue that data into the command for QUERY which is then piped into the input file.
As you can see piping is a very powerful tool for automating repetitive tasks and making older programs more user friendly.