HP30003k Associates LogoHP3000/HP 3000 FAQ

Last Updated: Thursday, February 01, 2007 02:38 PM

HP3000 FAQ

HPe3000 FAQ

HP 3000 FAQ

UDCs and Command Files

6.10. UDCs and Command Files


Be sure to check out the collection of MPE/iX command files at http://www.3kassociates.com/command_files

Part 1: WRITING A UDC FILE - One thing that every computer system worth its salt gives you is a way of packaging a bunch of commands into a file, and then executing them by referencing the file. Since you mentioned your IBM background, I'll flaunt mine: MVS calls this a "CLIST" (Command List?). MS/DOS calls it a "BAT" file. Unix calls it a command file (I think, or it might be a script...) (What *does* the AS/400 call this anyway?)

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...

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

MPE will automatically expand this to:

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:

pu harpo,chico,zeppo,groucho,gummo

...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...)


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
3)      You don't have to use SETCATALOG to enable a command
        file.  It's in effect as soon as you create it...

6.10.1. How to modify command files used in option-logon UDCs

An additional thing I do with my logon UDC(s) that use command files is:

  FILE tempfile;temp
  copy comfile,*tempfile

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.


Back to FAQ Index Back to 3k Home Page
HP3000-L FAQ Collection (c) 3k Associates, Inc. 1996-2006