Lesson 1 UDCs and Command Files [ Using the 900 Series HP 3000: Advanced Skills Module 5: User Commands ] MPE/iX 5.0 Documentation
Using the 900 Series HP 3000: Advanced Skills Module 5: User Commands
Lesson 1 UDCs and Command Files
Introduction
Lesson 1 presents a review of command files and an
introduction to UDCs. You will learn how to:
* distinguish between command files and UDCs
* print a UDC file and a UDC
* ensure that a UDC goes into effect at logon
NOTE In order to complete the exercises in this module, you need to be
in the CLASS group of your account.
Review of user commands
"User command" is a term for a user-specified short-hand command that
causes one or more MPE/iX commands to execute. Here are some samples of
user commands. The names of the user commands are the choice of the
user.
User MPE/iX
Command Commands
LF-------->LISTFILE
PR-------->PRINT
SM-------->SHOWME
SJ-------->SHOWJOB
SHOW------>SHOWME & SHOWJOB
As you know from previously creating command files, their main purpose is
to save users time and keystrokes when executing MPE/iX commands.
Types of user commands
There are two types of user command: command files and user- defined
commands, called UDCs.
Both command files and UDCs have the following features:
* contain one or more commands that MPE/iX can execute
* are useful for creating and executing frequently used commands or
command sequences that are long or complex
* utilize parameters and options
* can be easily changed to the other's format
* may invoke other files
* can be created with a text editor
UDCs, however, are sophisticated command files that have some added
features and differ in various ways from command files:
* need to be stored in a UDC file (which in turn is cataloged)
* can use two options not functional in command files
* execute when their command header is entered
Comparison of command files and udcs
Consider how the command files listed previously would appear as UDCs in
a UDC file, MYUDC1.
Figure 5-1. Command Files vs UDC File
Some of the differences you will notice are:
* Command file names (SHOW and SC) are not part of the command file.
* UDC names (SHOW and SC) are part of their respective UDCs and are
referred to as command
header names. UDCs are invoked by their command headers.
* Individual UDCs are separated by asterisks within a UDC file.
Asterisks must begin in column one.
Why use a command file for user commands?
There are many user benefits to using a command file for user commands.
First, command files are immediately executable after being kept. UDC
files must be cataloged before they will execute.
Second, command files can be easily modified and, if necessary, purged.
UDC files must first be uncataloged to be modified, and then recataloged
to be executable again. UDCs cannot be purged while they are cataloged.
Third, because command files are easy to use, many users create
their UDCs initially as command files. After they are sure that the file
"works," users transform the command file to a UDC file.
Why use a UDC file for user commands?
Despite the added effort to create and catalog UDC files, they provide
some features unavailable with command files.
One advantage is the order of execution. Commands stored in
a UDC file execute before those stored in a command file. (You will
learn about search and execution priorities in Lesson 2.)
Another important advantage is that UDCs can use a logon option that
allows the UDC to execute immediately upon the user's logon.
Yet another advantage of UDCs is that a UDC file is opened only once, and
then any of the UDCs within it are available for access at any time. (In
the case of command files, every time you call a command file, it must be
opened.)
UDCs use less disk space than the same number of individual command
files. They may also provide better organization of user commands since
they are all contained in the same file. Finally, UDC files have an
additional safety feature--they cannot be easily purged accidentally.
Listing UDC files
Consider the UDC files in your account. UDC files must be cataloged in
order for the UDCs to execute. This is done with the SETCATALOG command.
All cataloged files are displayed with the command:
SHOWCATALOG
Enter that command now from your keyboard.
SHOWCATALOG
Do you get the following listing of your UDC files? You should see the
fully qualified file name for MYUDC1 and these UDCs:
_______________________________________
| |
| |
| MYUDC1.CLASS.ACCTx |
| STARTUP USER |
| SETEQ USER |
| SHOWCAT USER |
| SM USER |
| SJ USER |
| |
_______________________________________
Reviewing a UDC file
Study the UDC file, MYUDC1. To list the contents of a UDC file, enter:
PRINT udcfilename
Do that now for MYUDC1.
PRINT MYUDC1
Here's what you should see on your screen:
_________________________________________________
| |
| |
| STARTUP |
| OPTION LOGON |
| SHOWJOB |
| SETEQ |
| *** |
| SETEQ |
| FILE IN=$STDIN |
| FILE OUT=$STDLIST |
| FILE OUTPUT=TESTFILE;REC=-80,,F,ASCII |
| FILE MAILPRNT;DEV=LP;ENV=ELITE.HPENV.SYS |
| FILE SLLIST;DEV=TAPE |
| *** |
| SHOWCAT |
| SHOWCATALOG |
| *** |
| SM |
| SHOWME |
| *** |
| SJ |
| SHOWJOB |
| *** |
| |
_________________________________________________
As mentioned earlier, UDC files may contain one or more UDCs with the
individual UDCs separated by asterisks. (Remember? No asterisks are
included in command files.)
How many UDCs are in MYUDC1?
If you said five, you're right. STARTUP, SETEQ, SHOWCAT, SM, and SJ are
the five UDCs contained in MYUDC1.
UDC characteristics
Each UDC begins with its command header or UDC name, for example,
STARTUP, followed by commands to be executed. (Command files are
executed by their file name; UDCs are executed by their command header.)
Logon UDCs
How could you ensure that a UDC would go into effect automatically when
you log on?
If you insert a line OPTION LOGON following the command header, the UDC
executes when you log on.
The logon option is useful for displaying
information regarding your current session, specifically the number of
jobs and sessions currently running on your system.
UDC files can use OPTION LOGON, but command files cannot.
Which of the UDCs in the MYUDC1 file goes into effect when you log on?
If you log on again, you should notice that the SHOWJOB command
automatically executes.
How to list a UDC
There may be times when you want to look at a UDC to find out which
commands are included. But what if you don't know under which UDC file
name the UDC was cataloged? Then you can use the HELP command to list
the contents of individual UDCs. For example, to list the contents of a
UDC called SETEQ, you would enter:
HELP SETEQ
UDCs can also be used to set up file equations. By
including your most common file equations in a UDC, you can avoid
retyping the equations every time you want to use them. Instead, you
only need to execute that UDC.
Lesson summary
1. UDCs and command files share a number of features; however, unlike
command files, UDCs are stored in a UDC file, which must be
cataloged before the UDCs may execute.
2. Use the following commands to get information about UDC files and
UDCs stored in your account:
SHOWCATALOG Displays cataloged UDC files
PRINT udcfilename Displays contents of a UDC file
HELP udcname Displays contents of a UDC
Exercise 5-1:lesson 1 review.
1. Check your knowledge of the characteristics of command files and
UDC files by marking which characteristics belong to each:
--------------------------------------------------------------------------------------------------
| | | | |
| | Characteristics | Command | UDC |
| | | Files | Files |
| | | | |
--------------------------------------------------------------------------------------------------
| | | | |
| a. | Must be cataloged. | | |
| | | | |
--------------------------------------------------------------------------------------------------
| | | | |
| b. | Uses commands and parameters. | | |
| | | | |
--------------------------------------------------------------------------------------------------
| | | | |
| c. | Command definitions must be separated | | |
| | by asterisks. | | |
| | | | |
--------------------------------------------------------------------------------------------------
| | | | |
| d. | Can easily be converted to the other. | | |
| | | | |
--------------------------------------------------------------------------------------------------
| | | | |
| e. | Executes the LOGON OPTION. | | |
| | | | |
--------------------------------------------------------------------------------------------------
| | | | |
| f. | Can be created with a text processor. | | |
| | | | |
--------------------------------------------------------------------------------------------------
| | | | |
| g. | Invoked by a command header. | | |
| | | | |
--------------------------------------------------------------------------------------------------
| | | | |
| h. | Invoked by a file name. | | |
| | | | |
--------------------------------------------------------------------------------------------------
2. A sample UDC file and command file are listed below. See if you
can answer the following questions regarding each of the files:
MYCOMM1.CLASS.ADVUSER MYCOMM2.CLASS.ADVUSER
SHOWME BEGIN
SHOWJOB OPTION LOGON
SHOWTIME SHOWJOB
*****
SM
SHOWME
*****
a. Which file is a command file?
b. Which file is a UDC file?
c. If both files are in your account, which MPE/iX command(s)
execute when you log on?
d. Which of the following are command headers in the example
above?
SM
SHOWCAT
MYCOMM2
MYCOMM1
BEGIN
SHOWME
3. Select the correct command to do each of the following:
---------------------------------------------------------------------------------------------------
| | | | | |
| | Function | HELP | SHOW | PRINT |
| | | UDC Name | CATALOG | Filename |
| | | | | |
---------------------------------------------------------------------------------------------------
| | | | | |
| a. | List all UDC files currently | | | |
| | cataloged for an account. | | | |
| | | | | |
---------------------------------------------------------------------------------------------------
| | | | | |
| b. | List the contents of a | | | |
| | specified UDC. | | | |
| | | | | |
---------------------------------------------------------------------------------------------------
| | | | | |
| c. | List the contents of a | | | |
| | specified UDC file. | | | |
| | | | | |
---------------------------------------------------------------------------------------------------
********** End of Exercise 5-1 ***********
MPE/iX 5.0 Documentation