Command Files
A command file is a file that contains a set of commands which will be executed when you type the name of the file (like a DOS batch file). Command files are similar to UDCs except that you do not need to catalog them. Like UDCs, command files can have parameters.
Qedit accepts command file names with or without the leading colon (“:”). You must precede the command file name with a colon if the name of the command file is the same as a Qedit command (e.g., :R, :L). Beware of some unobvious Qedit commands composed of abbreviations and options. For example, PRT is interpreted as a Qedit command (Proc with the template option.) If you have a command file call PRT, you must put a colon in front of it to have Qedit execute it as a User Command.
You can use command files as a “command language” to write customized functions in Qedit. Command files may contain MPE commands like :Listf, Qedit commands preceded with a slash, conditional logic commands such as :If and :Else, :While loops, Qedit-simulated MPE commands such as :Editerror, other command files, UDCs, external commands (%purge t@), and calculator commands (=5*80). You can include Qedit commands in a command file by preceding them with a slash “/”. Qedit commands in command files and UDCs will set the CIERROR JCW so that you can test the result of the command. See the /Qedit Command section for more details.
A command file can start with the optional header lines: PARM, ANYPARM and OPTION. These define the parameters and options of the command file. The command file terminates at the end of file or the first * line. If you need to pass an exclamation mark as parameter, use !! (for example, use !!xx
if you want to pass in the string !xxx
).
For example, here is a command file to print the spool files for a job number:
SSP.BOB.GREEN parm jobnum="0" if !jobnum > 0 then showout job=#j!jobnum endif
To invoke SSP.Bob.Green within Qedit, you just type
/ssp 67
Qedit follows the Hppath variable in searching for a command file named “ssp”. The default is to look in your logon group, then your Pub group, then Pub.Sys. You can override the default path by doing :Setvar Hppath on MPE/iX or Set Hppath on MPE V (simulated).
/:setvar hppath "!hpgroup,cmd,pub,pub.sys" {MPE/iX} /set hppath "!hpgroup,cmd,pub,pub.sys" {MPE V}
Warning: When you convert a UDC into a command file, don’t forget to replace the UDC name in the first line by the literal “PARM”. If you forget, you can easily create a recursive loop, since the PARM line is optional in command files. A command file can invoke itself recursively, but only up to 10 levels deep.
Restriction: Command files must be permanent files on MPE V, but they can be either temporary or permanent files on MPE/iX.
Variables in Command Files
On MPE/iX, commands in command files may refer to variables by preceding them with an exclam, just as you do for parameters (i.e., display !hpgroup
). On MPE V, Qedit allows you to refer to the value of a JCW in the same way (i.e., display !cierror
).
Here is a command file that updates a record with today’s date in YY/MM/DD format. The date is derived from the pre-defined HP JCWs hpyear, hpmonth, and hpdate:
TODAY.CMD.SYS /t file {replace columns 1/8 with date} /set win (1/8) /c 1/8 "!hpyear/!hpmonth/!hpdate" /l "/" (5/5) * {check for "/" in column 5} if qeditcount = 1 /c 4 "0" {insert leading 0 before month} endif /l " " (8/8) * {check for " " in column 8} if qeditcount = 1 /c 7 "0" {insert leading 0 before day} endif /set win ( )
The value of the JCWs hpmonth and hpdate may be single digits (for example on January 1, 2000) so we may need to insert leading zeros (99/1/1 becomes 99/01/01). We do this by testing for the existence of a “/” and a ” ” in specific columns. If there is a “/” in column 5, we know that the month value is a single digit.
I/O Redirection
On MPE/iX, you can have I/O redirection in command files. The “<” and “>” characters are used to specify I/O redirection, so there are some restrictions in using them in a command file’s Qedit commands.
Any occurrence of “<” or “>” means I/O redirection, unless these characters are part of a string. However, the string can only be delimited by a single quote (‘) or a double quote (“). The other string delimiters usually accepted by Qedit do not work. For example,
/find \<comment>\
works as a Qedit command on-line, but does not work in a command file, because the “<” and “>” are interpreted as I/O redirection.
Command Files Security
Qedit needs only Read or eXecute access to command files. However, for security reasons you should use only eXecute access. This way, no one will be able to look at the file contents, nor will they be able to use a Help command on it.
Users will be able to run only the command file.
QEFILE Variable
When executing a command file from inside Qedit, Qedit updates the variable QEFILE with the name of the file. This variable is a substitute for the MPE variable HPFILE, which is used in the same manner by the Command Interpreter.
You can write your command files using only HPFILE. During execution, Qedit replaces all occurrences of the word HPFILE wit QEFILE before executing each command. This way, your command files should execute the same way whether they run from the CI or from Qedit. You don’t have to check the INSIDEQEDIT JCW.
You have to keep in mind that, if you use Option List or if there are messages that contain HPFILE, the messages will now show QEFILE.
Warning and Error Messages
You can control the appearance of warning and error messages via the HPMSGFENCE variable when executing commands, UDCs and command files by MPE. Qedit has no way to check the value of this variable when it executes the same commands, thus HPMSGFENCE has no effect. An equivalent feature has been implemented via a user variable called ROBMSGFENCE. It uses the same values and meanings as HPMSGFENCE but applies only to commands executed by Qedit. You can change its value at any time and the change takes effect immediately.
setvar robmsgfence 1 {suppress warning messages} setvar robmsgfence 2 {suppress error and warning messages} setvar robmsgfence 0 {default, displays warning and error messages}
Here are some examples:
/purge nofile File "!" not found. No purge done. (CIWARN 383) /setvar robmsgfence 1 {suppress warnings} /purge nofile /build nofile;temporary Unknown keyword for BUILD command. (CIERR 299) /setvar robmsgfence 2 {suppress errors and warnings} /build nofile;temporary /setvar robmsgfence 0 {display errors and warnings} /build nofile;temporary Unknown keyword for BUILD command. (CIERR 299) /purge nofile File "!" not found. No purge done. (CIWARN 383)