HP3000 Script Programming: Creating MPE/iX UDCs and

Download Report

Transcript HP3000 Script Programming: Creating MPE/iX UDCs and

HP3000 Script Programming:
Creating MPE/iX UDCs and
Command Files
Presented by: Tim Ericson
DenKor Dental Management Corp.
1
Audience
Any new or experienced HP3000 user, programmer,
or systems manager. Familiarity with MPE/iX
commands is required, and experience with an
editor is needed. Today’s topic will range from the
introduction of UDCs and Command Files, to
examples of more complex solutions of everyday
problems.
2
Research
I’ve read a lot of papers on UDCs, JCWs, and
Command Files, and I’ve found several fantastic
ones! Today’s talk will use some of the examples
presented in those papers, and build upon them -kind of a “The best of the best”. I’ll have some
slides later that lists several of these papers.
3
Today’s topics
What’s Included Today? What are UDCs; What are
Command Files; The calling sequence of UDCs
and Command Files; System, Account, and UseLevel UDCs; Recursion; How HPPATH works;
Which manual to look in/Where to look on HP’s
documentation website
(http://www.docs.hp.com/mpeix) for more detail
(as we go along); CI Variables and Expressions;
Command Interpreter Functions available
(especially FINFO); Input and Output Redirection.
4
Free Samples!
UDCs and Command Files are frequently distributed
on the HP3000-L e-mail list, and some of these will
be used as examples throughout the discussion. I
have a few that I have created and use on a daily
basis, and several others have been sent my way for
this tutorial. I have posted them on my web page
(http://www.denkor.com/hp3000/command_files) to
be freely downloaded.
5
HP3000-L?
HP3000-L is a subscription e-mail list. To participate,
you must subscribe. After subscription you’ll receive
about 50-60 e-mail messages a day, and can submit
a question to the group (currently over 700
subscribers). Messages sent to HP3000-L are crossposted to the COMP.SYS.HP.MPE newsgroup, and
messages from there are likewise sent to HP3000-L.
6
What is a UDC?
A UDC is a User Defined Command, somewhat like a
Unix script or DOS BAT file, and can be a real timesaver. UDCs can be used to create shortcuts by
saving keystrokes or executing several command at
once. Once a UDC file is created, you must use the
SETCATALOG command to catalog the file so the
Command Interpreter (CI) can find it (more about the
SETCATALOG command later).
NOTE! Multiple UDCs (each with multiple commands)
can be saved in a single file!
7
What is a Command File?
A Command File is very similar to a UDC. Command
Files do not have to be cataloged, but must exist in
one of the directories in the HPPATH variable (more
about HPPATH and variables later, too).
NOTE! Only one set of commands be be stored in a
Command File!
8
HP’s Definition
From the Command Interpreter Access and Variables
Programmer’s Guide (found on the HP’s
documentation website): “The programming
capability of the CI can be used to simplify tasks.
Complicated routines requiring multiple commands
can be made transparent to users through the use of
command files and user-defined commands (UDCs).”
9
Creating A UDC or Command File
To create a UDC or Command File, you must use an
editor of some sort. The HP3000 has the system
EDITOR, but VI (in HPBIN.SYS), HPEDIT (from HP),
Qedit (from Robelle Consulting Ltd.), and QUAD (a
contributed editor) will all work (and there are
probably others). Add or change lines as shown in
the examples today, then save the new or changed
file.
10
Execution Sequence
Another quote from the Command Interpreter Access
and Variables Programmer’s Guide: “In processing
any command, the CI first checks the UDC files, then
the MPE/iX built-in commands. If no match is found,
the CI automatically searches for a program file or
command file of the same name” (by using the
HPPATH variable).
WOW! UDCs can override built-in CI commands!
NOTE! The “HELP” command works the same way!
11
More About UDC Sequencing
When the CI searches the cataloged UDCs, it first
looks at User-Level UDCs, then Account-Level UDCs
(the ;ACCOUNT option of the SETCATALOG
command), then System-Level UDCs (the ;SYSTEM
option -- on the next slide). If a UDC calls another
UDC, the called UDC must be specified after the
calling one (unless OPTION RECURSION is used -more about OPTIONs soon).
12
The SETCATALOG Command
From the MPE/iX Command Reference Manual, on
the SETCATALOG command: “Catalogs, or enables,
the user-defined commands (UDCs) in a specified
catalog file at the user, account, or system level. You
can also use this command to disable all UDCs on the
system.” (Remember -- this command is not
necessary for Command Files).
13
The First Example UDC
My first “best of” example is from Dave Largent’s “A
Beginner’s Guide to UDCs and JCWs” (an excellent
paper for those new to the HP3000 and UDCs), the
“J” UDC (we’ll talk about all the sections later):
J
OPTION LIST, HELP
SHOWJOB
**
14
Header Section
Options Section
Body Section
Separator Section
More SETCATALOG Info
To make the “J” UDC available to the user ACCT.PROD
(let’s say the UDC is stored in a file named
“JUDCFILE”, and we’re logged on as ACCT.PROD):
SETCATALOG JUDCFILE
To make the same UDC available to all users in the
PROD account (now we’re logged on as MGR.PROD):
SETCATALOG JUDCFILE;ACCOUNT
15
SETCATALOG Info, Continued
And to make the “J” UDC available system-wide
(we’re now logged on as MANAGER.SYS):
SETCATALOG JUDCFILE;SYSTEM
16
A similar Command File
Here’s that last example, but as a Command File
named “J” instead:
OPTION LIST, HELP
SHOWJOB
17
Options Section
Body Section
The HPPATH Variable
For Command Files, the CI uses the HPPATH variable
(remember that UDCs and built-in CI commands are
checked first). From the Command Interpreter
Access and Variables Programmer’s Guide: “By
default, the current group is checked first, followed
by the PUB group of the logon account, followed by
PUB.SYS and ARPA.SYS.”
18
More HPPATH Info
To make the “J” Command File available to the user
ACCT.PROD, the Command File must be saved as a
file named “J” in the group that the user is currently
logged into (let’s say the DATA group)
To have the save Command File available to all users
of the PROD account, the “J” Command File must be
saved in the PUB group of the PROD account.
19
HPPATH Info, Continued
Finally, to have the command file available to all
users on the system, the file must be saved into
PUB.SYS, or into another group (which must exist in
the HPPATH variable) that has execute access for
anyone on the system. I prefer not to keep any
system-wide command files in PUB.SYS, and have
created the XEQ.SYS group for this purpose.
20
DenKor’s HPPATH
On my machines, the HPPATH variable contains:
SETVAR HPPATH “XEQ.SYS,OBJ.COBACCT,
!!HPGROUP,PUB,PUB.SYS,ARPA.SYS,HPBIN.SYS”
Almost all of the Command Files are saved in
XEQ.SYS, which is checked before the COBOL
program group, the user’s home group, the user’s
PUB group, and PUB.SYS (no command Files are
saved in PUB.SYS!)
21
The Header Section
In a UDC, the header section is required because
that’s where the name comes from! The header
section can also be used to pass parameters into the
UDC. The header section in a Command File is only
needed when passing parameters.
To get values into a UDC, you must include variable
name(s) in the UDC’s header section, on the same
line as the UDC name, or include the PARM
statement with the variable name(s) on the next line
in that UDC. For Command Files, the PARM
statement, if used, is the first line in the Command
File.
22
Parameters
Jack Bailie, in his “MPE/iX Command File Tips and
Techniques” paper suggests that each parameter be
specified on a separate line, which provides
readability, and that we should only use meaningful
parameter names (Jack also has several other very
good suggestions on style in his paper - see my
website).
23
ANYPARM
ANYPARM is a special parameter which causes all
normal delimiters to be ignored. It must be the last
parameter specified, and anything in the command
line that appears after the last parameter has been
filled is passed in the variable in the ANYPARM
statement.
24
Adding Parameters to a UDC
Here we see how parameters are passed into a UDC
(the “L” command file, from Jack’s paper):
PARM fileset=@
ANYPARM format=DISC
LISTFILE !fileset, !format
Like this:
:L C@, DETAIL;PASS
25
The Options Section
There are several options available (as specified in
the Command Interpreter Access and Variables
Programmer’s Guide):
26
LIST or NOLIST
Controls the display of
each command image as it
is executed.
HELP or NOHELP
Controls the ability to
display the contents of
the UDC in help mode.
More Options
27
BREAK or NOBREAK
Controls the ability to
stop execution of a UDC.
LOGON or NOLOGON
Controls the automatic
execution of a UDC at
logon.
RECURSION or
NORECURSION
Controls the search for
UDCs called from another
UDC.
PROGRAM or
NOPROGRAM
Controls the ability of
a UDC to be executed
from a program.
The Body Section
The Body Section of a UDC or Command File is
where the real work gets done! Here is where the
Parameters passed in are worked on, files are
checked, and/or programs are run. For instance, we
could use the “IF” command with the “FINFO”
function to check if a file name passed as a
parameter exists or if the file contains any entries.
We’ll see more of this section as we continue.
28
The Separator Section
The Separator Section is only used in UDCs.
Separators are used to tell the CI that the end of the
current UDC has been reached, or the end of the
current UDC file has been reached. The Separator
line must begin with an asterisk (*), must separate
each UDC, and must be the very last line in a UDC
file.
29
UDC and Command File
Differences
Also in Dave’s paper is a very complete table of the
differences between UDCs and Command Files:
Comparison of User Defined Commands (UDCs) and
Command Files
Execution Considerations
User Defined Commands
Command Files
Invoked by typing the
name provided in the
header section of the
Invoked by typing
the command file's
file name.
UDC.
30
Differences, Continued
User Defined Commands
Command Files
Automatic execution
at logon time is
available.
Automatic execution
at logon time is
not available.
Executed before MPE
XL system commands
and command files.
May override CI.
commands.
Executed after UDCs
and MPE XL system
commands (unless
XEQ is used). May
not override CI
commands.
31
Differences, Continued
User Defined Commands
Command Files
User-, account-, and
system-level
definitions are
available.
Only "user-level"
definitions are
available. (Easy
access at any
level could be
established with
the PATH command.)
SHOWCATALOG lists
currently available
UDC names.
Cannot easily list
currently available
command file names.
32
Differences, Continued
User Defined Commands
Command Files
UDC file is more
secure. (More
difficult to purge
or alter a UDC
file.)
Command file is
less secure.
(Easier to purge
or alter command
file.)
Best used for
production or stable
command definitions.
Best used for
testing, development, or frequently
changing command
definitions.
33
Differences, Continued
Content Considerations
User Defined Commands
Command Files
Multiple command
definitions are
allowed per file.
Only one command
definition is
allowed per file.
Header section is
required.
Contains no header
section.
May have long,
descriptive command
name.
34
Command name is
limited to eight
characters (the
file name).
Differences, Continued
Maintenance Considerations
User Defined Commands
Command Files
Cataloging of the UDC
file(s) is required
before use.
Command files are
not cataloged;
Available
immediately after
creation.
Must un-catalog the
UDC file before
making changes to,
May make changes
to, or purge the
command file
or purging the file.
directly.
35
Differences, Continued
User Defined Commands
Command Files
May provide better
organization of
commands (fewer
files).
Organization may
not be as good
(more files to
keep track of).
System resource use
is heaviest at logon
time.
System resource
use is heaviest
at command file
execution time.
Less disk space is
More disk space
required.
is required.
36
Additional Differences
One more option -- RECURSION:
User Defined Commands
Command Files
OPTION RECURSION
required to force the
CI to re-start the
command search at the
first cataloged UDC.
No OPTION RECURSION
required to have the
CI start searching
at the first UDC.
37
RECURSION Subtleties
If OPTION RECURSION is not specified, any UDC that
calls another will only look for the called one after
the calling one -- the CI will look from the end of the
calling UDC to the end of the current UDC file, and
then in any UDC file that occurs after the current one
in the UDC catalog (like the Account-Level and
System-Level UDC files occur after the User-Level
UDCs).
38
RECURSION Subtleties,
Continued
If OPTION RECURSION is specified, any UDC that
calls another will cause the CI to start the search for
the called one at the very first UDC in the UDC
catalog (starting with the first User-Level UDC).
NOTE! This feature may be tricky if the UDC being
called exists at more than one level!
39
Variables!
Variables are used to store values during the current
session or job. They are available at the CI prompt,
from within UDCs and Command Files, and from
within programs (via intrinsic calls). There are a lot
of predefined variables, as well!
Variables come in three flavors: numeric, string, and
boolean. JCWs (job control words) are 16-bit
numeric variables, and as such are limited in value
from 0 to 65535.
40
Variable Names
Variable names can be up to 255 characters long and
can include dashes (-) and underscores (_), must
begin with an alpha or underscore character, but can
include numerics.
To prevent variables from being “stepped on” by
other UDCs and Command Files, it’s a good idea to
follow a naming convention. In a couple of the
examples that follow, I’ve used “MY_” as a prefix.
HP’s predefined variables all begin with “HP”!
41
Setting Variables
There are a few ways to set variables: SETVAR and
SETJCW (remember the limitation of JCWs);
HPCIPUTVAR and PUTJCW (both intrinsics); INPUT;
or as a PARM to a UDC or Command File. You may
even change the value of some predefined variables!
:SETVAR
:SETVAR
:SETVAR
:SETVAR
42
MY_NUMERIC 123
MY_STRING “ABCXYZ”
MY_TRUTH FALSE
MY_NEW_STRING MY_STRING + &
“!MY_NUMERIC”
Displaying Variables
Here are some ways to show what’s in a variable:
SHOWVAR and SHOWJCW; HPCIGETVAR, FINDJCW,
and GETJCW (intrinsics); and ECHO. Wildcards (“@”,
“?”, and/or “#”) can be used in the SHOWVAR
command.
:SHOWVAR MY_@
MY_NUMERIC = 123
MY_STRING = ABCXYZ
MY_TRUTH = FALSE
MY_NEW_STRING = ABCXYZ123
:ECHO !MY_STRING
ABCXYZ
43
Deleting Variables
The variables defined during any session or job will
disappear when you or the job logs off, but...
Like using a naming convention for your variables, it’s
a good idea to clean up after yourself when you’re
done with your variables. DELETEVAR and the
HPCIDELETEVAR intrinsic do this for you.
:DELETEVAR MY_@
:
44
Using Variables
With the exception of five commands (IF, ELSEIF,
WHILE, SETVAR, and CALC), you must use an
exclamation point (!) before a variable name to get
at its contents. In those four commands any nonnumeric or unquoted string is an implied variable
(implicit dereferencing)
Variables are available in all CI commands, as long as
you use an exclamation point (!) before the variable
name. The CI will substitute the value of the
variable in place of its name in the command (Explicit
dereferencing).
45
Recursive Dereferencing
You may include a variable name (with its
exclamation point) within the contents of another
variable! We’ve already seen this in the HPPATH
variable (notice the double exclamation points):
:SETVAR HPPATH,
“XEQ.SYS,!!HPGROUP,PUB.!!HPACCOUNT,PUB.SYS”
46
Recursive Dereferencing
The CI stores the variable-within-a-variable like this:
:SHOWVAR HPPATH
HPPATH = XEQ.SYS,!HPGROUP,PUB.!HPACCOUNT,
PUB.SYS
Whenever the ACCT.PROD,DATA user executes a
command, the CI interprets this as:
“XEQ.SYS,DATA,PUB.PROD,PUB.SYS”
47
Variable Localization
Just like the variables that you define during a job or
session disappear after you log off, UDC and
Command File parameters (from the PARM statement
in the Header Section) are local to that UDC or
Command File (and are not available to the CI after
the UDC or Command File is finished executing).
48
Local Variables
Ken Robertson of Robelle Consulting Ltd. in his paper
“Programming the Command Interpreter -- An
Introduction, a dog, and New Tricks” said it very
well:
“Local variables cannot be modified, and are
accessed only by reference within the command
files. If you have a local variable and a
permanent variable with the same name, then
the local variable takes precedence during
expansion.”
49
Local Variables, Continued
Ken continues:
“Make sure that your local variables have
different names from your permanent ones,
otherwise you’ll have more confusion than you
need at debugging time. The following command
file illustrates local versus permanent
variable referencing.”
parm hpjobname=“ZZTOP”
echo Good evening, !hpjobname.
Showvar hpjobname
50
Local Variables, Continued
Executing Ken’s command file (named “hithere”)
gives us:
:hithere
Good evening, ZZTOP.
HPJOBNAME = KEN
:
NOTE! As Ken points out: “The value of the local
variable will be returned during expansion only within
the command file that defines it.”
51
Predefined Variables
David Largent has written another outstanding
paper: “101 (More Or Less) Moral Things To Do With
HPSusan and The Other MPE/iX Predefined Variables
In The Harem”. A text version of this paper is
available on my web page.
Appendix A in the MPE/iX Commands Reference
Manual also has a section devoted to “Predefined
Variables in MPE/iX”.
Some predefined variables, like HPPATH, may be
changed. Others, like HPSUSAN, may not.
52
Variable Expressions
Variables can be combined and manipulated in
several ways. Appendix B in the MPE/iX Commands
Reference Manual has a complete list of the
expression evaluator functions (Table B-1).
These include arithmetic functions (integer only),
string manipulation functions, bit and boolean
operations, and variable and file information.
Variables are dereferenced implicitly within functions
(do not require the preceding exclamation point).
53
Expression Substitution
Expressions are dereferenced implicitly in the CALC,
SETVAR, IF, ELSEIF, and WHILE commands; but
must be dereferenced explicitly from within any other
command by enclosing the expression in square
braces ([]) and preceding it by an exclamation point:
:BUILD NEWFILE;DISC=![2*5000]
54
Testing Variables
Two variable functions are especially handy: BOUND
and TYPEOF.
BOUND (variable name or expression) returns TRUE
if the “variable name” (or the variable name returned
by an expression) exists.
TYPEOF (variable name or expression) returns “0” if
the “variable name” is invalid, “1” if it’s an integer,
“2” if it’s a string, and “3” if it’s a boolean.
55
Getting File Information
One of the most handy features of the expression
evaluator is the FINFO function. FINFO has two
arguments, the file name you’re looking for info on,
and what you’re looking for.
Table B-2 in Appendix B of the MPE/iX Commands
Reference Manual has a complete list of all the
FINFO options (so does :HELP FINFO!)
NOTE! FINFO options may be numeric, like “19”, or a
more descriptive word, like “EOF”. It’s good practice
to use the more descriptive form.
56
New FINFO Options
As of the MPE/iX 5.5 Express 3 Release, FINFO has 5
new items not listed in the manual or in the HELP
subsystem:
Num.
Mnemonic
Return Type
58
59
60
-60
SECTORS
EXTENTS
CREATETIME
INTCREATETIME
Integer
Integer
String
Integer
ACCESSORS
Integer
61
57
User INPUT
Besides the PARM and ANYPARM options we learned
about earlier, you may get data from a user with the
INPUT command. The command has four
parameters, the variable name to store the user’s
answer in, the prompt the user sees, the length of
time (in seconds) the user has to answer the
question, and the number of characters to accept as
input (the last two are optional).
INPUT is also available as an expression evaluator
function (see Appendix B in the MPE/iX Commands
Reference Menu).
58
The “Menu” Command File
From the Command Interpreter Access and Variables
Programmer’s Guide is a very simple “Menu”
Command File:
ECHO Enter 0 to
ECHO
1 to
ECHO
2 to
INPUT CHOICE, &
“Which number
exit.
review database.
update database.
do you select?”,15
NOTE! 15 seconds is probably too short for everyday
use!
59
Using IF and ELSEIF
From the same manual we learn about branching, so
we can have some control over what happens in any
UDC or Command File:
IF CHOICE = “1” THEN
DBREVIEW
ELSEIF CHOICE = “2” THEN
DBUPDATE
ENDIF
Notice the indentations used for readability.
60
Looping
The WHILE statement gives the CI the ability to
repeat a series of commands. Building on the
“Menu” Command file, and combining the IF and
ELSEIF commands (from the Command Interpreter
Access and Variables Programmer’s Guide):
SETVAR CHOICE “ “
WHILE CHOICE <> “0” DO
ECHO Enter 0 to exit.
ECHO
1 to review database.
ECHO
2 to update database.
61
Looping, Continued
INPUT CHOICE, &
“Which number do you select?”,15
IF CHOICE = “1” THEN
DBREVIEW
ELSEIF CHOICE = “2” THEN
DBUPDATE
ENDIF
ENDWHILE
(DBREVIEW and DBUPDATE must be two other
command files)
62
Output Redirection
Usually, the output from a UDC or Command File will
either show up on your screen, or in your job’s
$STDLIST. To put the output in a file instead, use
the “>” symbol to “redirect” the output.
You may use file backreferencing to override the CI
default (80 bytes, variable length ASCII, 10000
record, temporary file, NOCCTL) for output
redirection.
“>>” will append the re-directed output to the end of
an existing file.
63
Using Output Redirection
One of the best things about UDCs and Command
Files is the ability to create lists of things and do
repetitive actions on them. For instance, we could
use Jack Bailie’s “L” Command File example to put a
listing of our “AP” files into a disc file, and then
create another Command File to work on that list. To
redirect the “L” Command File’s output into a disc
file, we’d do:
:L AP@,6 > APFILES
64
Input Redirection
Input redirection works just like output redirection,
but uses in “<“ symbol to “direct” the input from
whatever file you specify.
For example, you could put a bunch of EDITOR
command into a disc file and then use input
redirection to send them to the EDITOR:
:EDITOR < EDCMDS
65
Reading a file
There are a few different ways to get the contents of
a disc file into a UDC or Command File, two that are
not very efficient, and a third that’s a little harder to
comprehend, but very efficient.
The PRINT command.
Message (;MSG) files.
Command Input/Output Redirection (CIOR)
66
Using the PRINT Command
MPE/iX’s PRINT command has the “;START=“ and a
“;END=“ options, and can be used with redirection to
extract a single line from a file and put it into another
file:
PRINT APFILES; START=3; END=3 > APRECORD
67
Inputting a single line
The contents of this new file, APRECORD, can then
be sent with Input Redirection into a UDC or
Command File by using the INPUT command:
INPUT AP_REC < APRECORD
NOTE! Using input redirection this way only reads
the first line of the file!
68
Reading a file with PRINT
Putting this method into a WHILE loop, it gets rather
messy:
SETVAR AP_EOF, FINFO ( “APFILE”, “EOF” )
SETVAR AP_LINE, 1
WHILE AP_LINE <= AP_EOF
PRINT APFILES; START=!AP_LINE; &
END=!AP_LINE > APRECORD
INPUT AP_REC < APRECORD
# DO SOMETHING WITH AP_REC
SETVAR AP_LINE, AP_LINE + 1
ENDWHILE
69
Using a Message File
By using a file equation to define our original output
file as a message file, and using a file backreference,
we can put the listing into a file that will “shrink” as
records are read from it (whenever a “read” is done
on a message file, the record is deleted from the
file).
Our prior example changes to look like this:
:FILE APFILES;MSG
:L AP@,6 > *APFILES
:RESET APFILES
70
Reading a Message File
Now the UDC or Command File becomes quite a bit
simpler, because we don’t need a second output
redirection to get the record from the file. A WHILE
loop that checks for our input file’s eof works very
well (the first record in APFILE will be deleted during
each INPUT, until the file is empty):
WHILE FINFO ( “APFILES”, “EOF” ) > 0
INPUT AP_REC < APFILES
# DO SOMETHING WITH AP_REC
ENDWHILE
71
Command Input/Output
Redirection (CIOR)
CIOR has one big benefit over using the PRINT
command and over message files, the number of file
opens, file closes, and record I/Os are significantly
reduced!
I was initially confused by CIOR -- not by input
coming from one source and output going to another,
but by the use of both in the same Command File! A
note from Jeff Vance of HP’s CI Lab gave me the
push I needed to explore a little more.
72
CIOR, Continued
We’ve already seen how to send a Command File’s
output to a disc file with Output Redirection, and
we’ve seen how to use Input Redirection, like in the
EDITOR example -- but not together.
Combing Jack’s “L” Command File’s output with a
new Command File that displays the file creator for
any file name passed to it, we’re beginning to get
something useful!
73
The CREATR Command File
Here’s the contents of “CREATR”:
SETVAR AP_LINE, 1
SETVAR AP_EOF, FINFO ( "APFILES", "EOF" )
WHILE AP_LINE < AP_EOF
INPUT AP_FILE
ECHO FILE ![ RTRIM ( "!AP_FILE" ) ] &
CREATOR IS:
![ FINFO ( "!AP_FILE", "CREATOR" ) ]
SETVAR AP_LINE, AP_LINE + 1
ENDWHILE
DELETEVAR AP_@
74
Using “L” and “CREATR”
Putting it all together:
:L AP@,6 > APFILES
:CREATR < APFILES
FILE APINPUT.PROG.ACCT CREATOR IS: MGR
FILE APOUTPUT.PROG.ACCT CREATOR IS: USER
FILE APREAD.PROG.ACCT CREATOR IS: TIM
:
But that’s two separate Command Files! How about
doing that in one step?
75
Entry Points
Parts of a UDC or Command File can be made to only
execute under certain conditions with the “IF”
command. By using a parameter to determine which
portion of a UDC or Command File will be executed,
we can effectively combine two UDCs or Command
Files into one!
76
The FIND Command File
Jack Bailie has a great example Command File called
“FIND” in his “MPE/iX Command File Tips and
Techniques” paper that shows how to use entry points:
PARM fileset=@
PARM entry=MAIN
IF (“!entry” = “MAIN”) THEN
LISTFILE !fileset,QUALIFY > FINDTEMP
XEQ FIND ENTRY=“NOTMAIN” < FINDTEMP
PURGE FINTEMP,TEMP
77
The FIND Command File
ELSE
SETVAR _find_i 1
SETVAR _find_eof FINFO(“FINDTEMP”,”EOF”)
WHILE (_find_i < _find_eof) DO
SETVAR _find_file INPUT()
SETBAR _find_file RTRIM(_find_file)
SETVAR _find_creator &
FINFO(_find_file,”CREATOR”)
ECHO !_find_file !_find_creator
SETVAR _find_i _find_i + 1
ENDWHILE
ENDIF
DELETEVAR _find_@
Performance Considerations
To keep your UDC or Command File running in tiptop shape (and save some CPU time!), there are a
couple of things you can do:
Use “#” for comments instead of “COMMENT”. The
CI recognizes the “#” much sooner.
If possible, use SETVAR commands outside of your
loops to prevent expressions from being evaluated on
each instance of the loop.
79
Performance Considerations
Remember to stay away from the one-line-at-a-time
PRINT method and the message file method when
reading files in a while loop.
Combine as many SETVARs and Variable Expressions
into long statements whenever you create a WHILE
loop -- although this may create difficult-to-read
UDCs or Command Files.
80
Wrapping it up
We’ve now covered most of the basics for UDCs and
Command Files, and have had a taste of some of the
more advanced things we can do with them. Just a
few more things before we’re finished...
81
Good Documentation
Be sure to use comments (#) or ECHO statements to
document your UDCs and Command Files. Take
credit for being the author, and put the creation date
and any modification dates in there as well!
Your peers and users will bother you much less
frequently when the “how”s and “why”s are already
in the file!
82
Where to go for more!
The Command Interpreter Access and Variables
Programmer’s Guide (found on the HP
documentation website:
http://www.docs.hp.com/mpeix). A very good
introduction to the Command Interpreter (the CI),
and a lot about UDCs and Command Files.
The MPE/iX Commands Reference Manual (also on
the website) for command descriptions and Appendix
B for information on the expression evaluator.
83
More more!
HP’s Jazz Web Server: http://jazz.external.hp.com
(running on an HP3000!)
My Web Page:
http://www.denkor.com/hp3000/command_files
(special thanks to DenKor for hosting this site!)
Several free samples and examples are here!
Subscribe to HP3000-L! Send an e-mail to
[email protected] with “subscribe HP3000-L
<Your Full Name>” as the only line in the body of
the message.
84
Other Papers to link to
The following papers are available as links from my
web page:
• "MPE Programming" by Eugene Volokh of VeSoft,
presented at the 1983 (Montreal) HPIUG
Conference
• "MPE/XL Programming" by Eugene Volokh of
VeSoft, presented at the 1988 (Orlando)
Interex Conference
• “A Beginner's Guide to UDCs and JCWs" by David
L. Largent
85
Other Papers to link to
• 101 (More or Less) Moral Things To Do With
HPSusan..." by David L. Largent, presented at
the 1993 (San Francisco) Interex Conference
• “MPE Command File Tips and Techniques (50slide MS PowerPoint Presentation)" by Jack
Bailie, presented at the 1993 (San Francisco)
Interex Conference
• "Command File Tips and Techniques" by Jack
Bailie, presented at the 1993 (San Francisco)
Interex Conference, and printed in the March,
1994 Interact Magazine
86
Other Papers to link to
• "Programming the Command Interpreter" by Ken
Robertson of Robelle, presented at the 1995
(Toronto) Interex Conference
• "UDCs and Command Files" from the HP3000 FAQ,
Topic 6, Item 10
• “A Detailed Look at CI Enhancements" by Jeff
Vance of Hewlett Packard (from 5.5
Communicator)
87
Other Papers to link to
• "MPE/iX Release 5.5 Express 3 CI
Enhancements" by Jeff Vance and M.
Gopalakrishnan (Gopi) of HP
• "5.5 MPEJXQ1 CI Enhancements" by Jeff Vance
of Hewlett Packard
88
Other Papers to find
These papers I’d really like to have copies of or links
to on my web page:
• "Design Features of the MPE/XL User Interface"
by Jeff Vance and John Korondy, presented at
the 1987 (Las Vegas) Interex Conference
• "The Life of an MPE XL Command -- Advanced
Concepts in MPE XL CI Programming" by Scott
Cressler and Jeff Vance, printed in the
September, 1989 Interact Magazine
89
Other Papers to find
• "Writing and Applying MPE XL Command Files" by
Fred Ochs, Jr., printed in the September, 1991
Interact Magazine
• "UDCs vs. Command Files" by Bruce Pratt,
printed in the September, 1992 Interact
Magazine
90
Special Thanks
The following people have helped me a great deal
with their encouragement and support (and papers
and presentations to study!):
David Largent
Ken Robertson
Jack Bailie
Jeff Vance
Eugene Volokh
91
Thank You!