User Defined Commands
You can execute MPE User Defined Commands, also known as UDCs, inside Qedit. You must first do a Set Udc command to tell Qedit which UDCs to recognize. To check on your UDCs, use Verify Udc, :Setcatalog and :Help udc.
The wider concept, User Commands, includes both UDCs and command files. Command files are like UDCs, but do not have to be cataloged, since each file contains a single command whose name is the file name itself. Many users are switching from UDCs to command files, because the maintenance is easier.
Qedit accepts UDC commands with or without the leading colon (“:”). You must precede a UDC name with a colon if the name of the UDC 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) so you must put a colon in front of it to have Qedit execute it as a User Command.
UDCs may contain MPE commands such as Listf, conditional logic commands such as If-Else-Endif and While-Endwhile, Qedit-simulated MPE commands such as :Editerror or isplay, other UDCs, command files, calculator commands (=5*80), external commands (%purge t@), and Qedit commands (precede them by a slash, as in /list abc). 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 for more details.
Sample UDCs
UDCs allow you to abbreviate the MPE commands that you use frequently and to create complex new commands. We provide a sample UDC file in the Robelle account that you may find useful:
/set udc udc.catalog.robelle /:showcatalog UDC.CATALOG.ROBELLE PROSE USER PDISC USER SEG USER TIME USER SPOOK USER DUP USER /:help time USER DEFINED COMMAND: time comment show the date and time showtime /:time FRI, OCT 14, 2000, 9:24 PM /:SPOOK {runs spook on any CM system}
Restriction on Qedit UDCs
There are three restrictions on the User Commands that Qedit can handle: no more than 32 parameters or more than 256 bytes of parameters, no expanded line greater than 279 characters, and no I/O redirection on MPE V.
Qedit supports If/Else commands and the While-Endwhile loop of MPE/iX, but the CIERROR JCW is not updated exactly the same as MPE for all errors.
INSIDEQEDIT JCW
Since UDCs and command files are not exactly the same when executed inside Qedit, as they are when executed by MPE, we provide a JCW that tells you where you are. INSIDEQEDIT is set to 0 the first time you run Qedit. You should also set it to 0 in your logon UDC. If you do a ShowJCW, INSIDEQEDIT will always show a value of 0. When you refer to INSIDEQEDIT from within Qedit (in an If or While command), Qedit does not look at the real JCW. Instead, it inserts a constant value of 1. Nor does Qedit set the real JCW to 1; it is still 0. Thus, you have a JCW that acts differently within Qedit, giving you a way to find out where you are. Since /Qedit commands can only be executed when the command file is executed by Qedit, the INSIDEQEDIT JCW gives you a way to test this.
if insideqedit=1 then run spook5.pub.sys;hold else run spook5.pub.sys endif
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)
UDC Security
Some users have altered the security of Command.Pub.Sys to be (X,L:ANY; R,A,W:CR). If you do this, the Set Udc On command will not be able to search Command.Pub.Sys. Use Set Udc with file names instead.
UDCs with Parameter Substitution
Here are two UDCs with parameters, :Compare and :Seg.
/set udc compudc.catalog.robelle /:help compare USER DEFINED COMMAND: COMPARE filea, fileb, outfile="$STDLIST", info="" comment comment Compare two files using the Compare program. comment file filea=!filea file fileb=!fileb file outfile=!outfile run compare.pub.robelle;info="!info" reset filea reset fileb reset outfile ****
You invoke the Compare UDC by entering:
/:compare *,origfile {* means current workfile}
In Qedit, an * as a parameter to a User Command substitutes the name of your current workfile or the last one you Shut. As well, $ as a parameter substitutes the name of the last external file name mentioned (Verify Lastfile).
The Seg UDC gives you the ability to execute a file of :Segmenter commands without typing them interactively and without streaming a batch job.
/setcatalog udc.catalog.robelle /:help seg USER DEFINED COMMAND: seg parm1 comment execute segmenter commands from a file. run segdvr.pub.sys;stdin=!parm1 *
To invoke Seg, specify the file name that contains Segmenter commands:
/:seg seg055
Variables
On MPE/iX, commands in UDCs and command files may reference variables by preceding them with an exclamation mark, just as you do for parameters (e.g. display !hpgroup
). Variables are also allowed in MPE commands which you enter through $stdin or a usefile. On MPE V, Qedit allows you to refer to the value of a JCW in the same way (e.g., display !cierror).
Current Workfile (*)
The rose command is even more useful than it appears, due to an extension to the UDC-concept that Qedit provides: * as a parameter is replaced by the name of the current workfile, or the workfile just closed if none is Open. Thus, you can easily edit and print a Prose document from within Qedit:
/open rpt003.doc {open file for changes} /modify ... {edit the document} /set udc udc.catalog.robelle /:prose * {print final-stop with control-y} {Prose may take a while} /modify ... {more changes...} /add .001 {select pages to print} 0.001 .sel (1:4) 0.002 // /:prose *,*lp {print copy on line printer}
When you specify * as a UDC parameter and the current file is in your logon group, Qedit passes the unqualified file name as the UDC parameter instead of the fully qualified file name. This allows you to append group names to it in the UDC body.
Options for UDCs
Qedit supports the MPE options for List, Nohelp, and Nobreak, plus:
OPTION NOERROR {suppress all MPE error messages} OPTION NOWARN {suppress all warning messages}
Option List, Nolist, Recursion and Norecursion can be used at the beginning of a UDC as well as anywhere in the body of a UDC to enable or disable the corresponding feature. Other options are recognized only at the beginning of the UDC.
Option List and Nolist controls the display of individual commands that make up a UDC. When Option List is encountered, Qedit echoes every command back to $stdlist as they are executed. Option Nolist suppresses the display. The option can be enabled and disabled as often as needed.
In addition to User, Account and System UDCs loaded with Set Udc On, you can add session-level UDCs. These are loaded by the Set Udc filename command and are valid for the duration of the current Qedit session.
You can have session header and trailer UDCs. Session header UDCs precede the MPE-equivalent UDCs loaded with Set Udc On. Session trailer UDCs follow these same UDCs. For example, if you use all UDC levels, you would have:
- Session header
- User
- Account
- System
- Session trailer
Even though the first and last levels are designated as session UDCs, Qedit treats them as separate, unrelated levels.
Set Udc On loads all 3 levels automatically. If you wish to load files from a single level, you have to use Set Udc filename to load individual files.
When Qedit searches UDCs, it starts from the session header level and goes down the list. By default, a UDC can only call a UDC that is defined at a lower level. This is non-recursive execution.
In some instances, it might be desirable or necessary to call UDC that is higher up in the search order. To achieve this, you can insert an Option Recursion statement in the calling UDC. From that point, Qedit starts the search at the top of the current level. For example, if the UDC currently executing is at the Account level, the search starts with the first account UDC. If the currently executing UDC is a Session Trailer, the search starts with the first session trailer UDC.
To disable recursion, insert an Option norecursion statement at the desired location. Recursion can be disabled or enabled as often as needed.
Because recursion can cause infinite loops if not used properly, UDCs can be nested only 30 levels deep or until allocated stack space is used up.