HP3000/HP 3000 FAQ
Last Updated: Thursday, February 01, 2007 02:38 PM
UDCs and Command Files
Be sure to check out the collection of MPE/iX command files at http://www.3kassociates.com/command_files
Anyhow, the old MPE/V operating system called this thing a "User Defined Command" file, or UDC. You use the editor of your choice to type in a file that contains the commands you'd want to execute.
UDCs have a couple of unique characteristics. For example, each file contains not just one command, but several of them. Each command that you define is separated by a line of one or more asterisks. The first line of each command that you're defining defines the name of the UDC. The remaining lines are the commands that will be executed when you reference the UDC by this name...
For example: Here's a sample UDC file...
sj showjob **** ls listf *** ll listf ,2 ***
This file contains three commands. If you type the command "sj", the system will execute the command "showjob". Similarly, if you type the command "ls", the system will execute the command "listf", and if you type the command "ll" the system will execute the command "listf ,2".
Next, we'll show you how to put keywords on your UDCs. The first line of the udc defines the name of the command that you're defining, followed by the names of the keyword or keywords, and any default values you may want to assign. The body of each UDC references the keywords using a "shriek" character (!) followed by the keyword itself.
Here's a simple example:
p file print !file ***
This UDC defines a command called "p". When you type the command "p", you must follow it by a filename. For example, if you type the command
:P MYFILE MPE will automatically expand this to: :PRINT MYFILE... Here are some more examples: ls <----- If you type "ls", the system will listf execute the command "listf" with no *** keywords. But if you type the ll name <----- command "ll", you *must* supply a listf !name,2 filename. (E.G :LL MYFILE) and *** MPE will do a :LISTF MYFILE,2 dir name,level=2 <----- You can give a default value to listf !name ,!level a keyword if you like. So, for *** example, if you type: :DIR MYFILE,0 The system will expand that to :listf myfile,0 But if you type :DIR MYFILE MPE will allow "level" to default to "2", and expand your UDC to: :listf myfile,2
One more thing. A UDC can contain multiple commands. For example, the old MPE/V PURGE command could only purge one file at a time. For this reason, lots of folks had UDCs on their systems to purge more than one file at a time. Here's an example.
pu file1,file2=$null, file3=$null, file4=$null, file5=$null purge !file1 purge !file2 purge !file3 purge !file4 purge !file5 ***
In this example, you can use the user defined "pu" command to purge up to five files. So for example, you can type the command:
...to purge five files named harpo, chico, zeppo, groucho and gummo. If you don't specify all five parameters, then the defaults take effect. For example, suppose you type
pu moe, larry, curly
MPE will expand the above "pu" user defined command into the following five MPE commands:
PURGE MOE The 1st 3 purge commands use the PURGE LARRY values you supplied in the "pu" PURGE CURLY command. The last 2 purge commands PURGE $NULL take the default value. ($NULL is PURGE $NULL MPE's name of the "bit bucket" or "null file". Any attempt to purge it is ignored...)
Part 2: ENABLING A UDC FILE
When you create a UDC file, it doesn't make any difference what name you give to the file. The file that contains your UDCs can be given *any* name you like. This means that, somehow, you have to tell MPE that this file contains commands, so that when you type commands, MPE will check the file to see if there's something in there that matches what you typed. This is done using an MPE command called "SETCATALOG".
So for example, if you create one of the file shown above and call it GEORGE, you could type "sj" or "pu" all day long and MPE would not recognize these as user defined commands. Before the UDC will work you must enable the UDC file by typing the command
SETCATALOG ensures that from this point forward, whenever you type a command, MPE will first check your file (GEORGE) and look for a user defined command that matches the command that you just typed. If it finds one, it will execute the command(s) defined in the UDC.
You can use the command :SHOWCATALOG to see what UDCs have been enabled for you.
If you are logged on as the system manager, or as an account manager, you have some additional capabilities that you can use with the SETCATALOG command. For example, the system manager can enter the command :SETCATALOG GEORGE;SYSTEM This causes the UDCs defined in the file GEORGE to be in effect for all users on the system. (Actually the UDC will take effect the next time they log on, not immediately). Account managers also have an option that enables a UDC for all users in an account, but I'll leave it up to you to type :HELP SETCATALOG on your 3000 to find out how that works.
I hope this has been helpful. If you're on an MPE/iX machine, you may also want to look into command files. The command file funcationality is similar, in some respects, to UDCs. The differences, in a nutshell, are that:
1) You reference the command file by its name. So if you save it in a file called "GEORGE", then you type the command :GEORGE to execute its contents. 2) Command files give you some additional functionality, (IF, THEN, ELSE, ENDIF, DO WHILE,) that's not (to my knowledge) available with UDCs. (It's been a while since I've been logged on to an MPE/V system, and I know Roseville has put a number of enhancements into the O/S that I'm not aware of...) 3) You don't have to use SETCATALOG to enable a command file. It's in effect as soon as you create it...
UDCNAME OPTION LOGON, NOLIST, NOBREAK FILE tempfile;temp copy comfile,*tempfile tempfile bye
By copying the command file to a temporary file and then having the UDC execute the temporary command file, it allows me to change the command file out from under my users while they are logged on.