Command Sequences [ HP Transact Reference Manual ] MPE/iX 5.0 Documentation
HP Transact Reference Manual
Command Sequences
You can structure the body of a Transact program around command sequences
specifically designed for a particular interactive interface to the
program. A command sequence consists of the statements placed between a
command or a subcommand and the next command, subcommand, or END
statement, whichever comes first. One command sequence in Figure 5-1
begins with the statement following the subcommand $C and ends with the
statement preceding $PAYMENT. The statements after $P and before $$UPDATE
are also considered a command sequence.
Command sequences divide the Transact program into functional parts that
make logical sense to you and that are meaningful to the user.
One or more functions in a Transact program can be contained in a command
sequence. Each sequence is headed by a command label such as $$ADD or
$$UPDATE and possibly one or more subcommand labels such as $CUSTOMER.
Command and subcommand labels are followed by statements. Each sequence
ends with another command label or an END statement.
___________________________________________________________________
| |
| SYSTEM CINFO, |
| BASE = CUST(,3,1); |
| |
| $$ADD: |
| $$A: |
| $CUSTOMER: <<Add a new customer to the database>>|
| $C: |
| |
| PROMPT CUST-NO("Enter customer number "): |
| CUST-NAME("Enter customer name "): |
| CUST-ADDR("Enter customer address "); |
| PUT CUST-MAST; |
| |
| $PAYMENT: <<Add payment to A/R data set>> |
| $P: |
| |
| PROMPT CUST-NO("Enter customer number "), |
| CHECK = CUST-MAST: |
| PDATE("Enter payment date "): |
| INV-NO("Enter invoice number "): |
| AMOUNT("Enter amount of payment "); |
| PUT AR-DETAIL; |
| |
| $$UPDATE: |
| $$U: |
| $ADDRESS: <<Change customer's address>> |
| $A: |
| PROMPT CUST-ADDR("Enter customer address "); |
| UPDATE CUST-MAST, LIST=(CUST-ADDR); |
| |
| $$DELETE: |
| $$D: |
| $CUSTOMER: <<Delete old customer from database>> |
| $C: |
| PROMPT(KEY) CUST-NO("Enter customer number "); |
| DELETE CUST-MAST; |
| |
| END CINFO; |
___________________________________________________________________
Figure 5-1. Program Using Command Sequences
Processing Command Sequences
When Transact executes a program, it starts by executing any statements
between the SYSTEM statement and the first command label of the root
segment. If there is no command label in the root segment, Transact
executes statements between the SYSTEM statement and the end of the root
segment. When Transact encounters the first command label, it issues the
prompting character > to tell the user to enter a command. The user must
respond to this prompt with a command name defined in the program
followed by a subcommand name, if there is one. The response that the
user gives determines which command sequence is executed.
Before each command sequence is executed, Transact resets all of the
registers used for data storage and other data management functions,
although it does not actually clear any data. Registers are described in
Chapter 4.
When the sample program in Figure 5-1 is executed, the user might enter
any of the following in response to the prompting character:
> ADD CUSTOMER
> ADD PAYMENT
> UPDATE ADDRESS
> DELETE CUSTOMER
Command and Subcommand Labels
A command label is preceded by $$ and a subcommand label is preceded by
$. Both are followed by colons, as in:
$$command:
$subcommand:
Either label can contain from 1 to 16 characters in addition to the
leading $$ or $. The label must begin with an alphanumeric character.
The remaining characters can be any characters except the delimiters ($ ,
; : = < > ( ) [ ] " or a blank). All command and subcommand labels are
global to the program and can be referenced from any program segment.
(See "Program Segmentation" in Chapter 9.)
You can provide the user with short forms for commands and subcommands.
These short forms are illustrated for each command and subcommand in
Figure 5-1.
A command label must have at least one character following the $$, for
example, $$A:. A subcommand, however, can have a null value, as in $:.
The following code shows a null subcommand:
$$CHANGE:
$ADDRESS:
$:
The null subcommand in this example allows the statements following it to
be executed whether the user enters:
> CHANGE ADDRESS
or merely
> CHANGE
User-Entered Passwords for Commands and Subcommands
You can require that a user enter a password to execute a
command/subcommand sequence. A password can be a 1-8 character string of
any combination of alphanumeric or special characters. Passwords must be
specified exactly as they were defined. Thus, if a password was defined
with all uppercase characters, then it must be specified with all
uppercase characters in your program and entered by the user with all
uppercase characters. To request passwords, use the following syntax:
$$command("password"):
$subcommand("password"):
Consider the following code:
$$ADD("PQX2"):
$CUSTOMER:
When the user enters the command
> ADD CUSTOMER
Transact requests the password:
COMMAND PASSWORD>
In order to execute the statements associated with the command ADD
CUSTOMER, the user must enter the correct password, PQX2:
COMMAND PASSWORD> PQX2
Note that the password is in uppercase not pqx2 (lowercase). Passwords
must be exact.
Subcommands as well as commands can require passwords:
$$ADD("PQX2"):
$CUSTOMER("MKC"):
When the user enters the command:
> ADD CUSTOMER
Transact requests both passwords:
COMMAND PASSWORD> PQX2
SEQUENCE PASSWORD> MKC
If the user enters an invalid command password, Transact responds with:
INVALID COMMAND PASSWORD
If the user enters an invalid password for a subcommand (or sequence),
Transact responds with:
INVALID SUB-COMMAND PASSWORD
In either case, Transact issues a prompt for another command.
Built-in Commands
Certain commands are built into Transact and are available to the user if
the program uses a command structure. These commands influence the
execution of Transact and include the following:
COMMAND [command-name] Lists all the commands, or lists all the
subcommands associated with the specified
command name, in the currently loaded program.
An "*" will be displayed for null subcommands.
EXIT Generates an exit from Transact.
INITIALIZE (Transact/V only) Generates an exit from the
current program and initiates the loading of a
new program.
When you enter INITIALIZE, you are prompted
with SYSTEM NAME>.
RESUME Causes the resumption of a process that was
interrupted by a Ctrl Y. (Ctrl Y is explained
later in this chapter under "Special Characters
that Control Program Execution".
TEST[,mode [,range]] (Transact/V only) Causes Transact to execute in
test mode for the specified range; if no mode
is specified, test mode is turned off.
If you define a command in your program with the same name as these
built-in commands, the program defined command takes precedence.
Command Qualifiers
Transact program commands, such as ADD CUSTOMER or UPDATE ADDRESS, can be
qualified by using command qualifiers. The qualifiers that are
recognized by Transact include:
FIELD Indicates the prompted-for field length on HP 264X series
terminals.
PRINT Directs output to the line printer instead of to the
user's terminal.
REPEAT Repeats a command sequence until a termination character
("]") is entered for a prompt other than the first field
of a command sequence. Entering a "]" for the first
field prompt or "]]" for any field prompt returns control
to the command mode regardless of the level of command or
subcommand. However, if there is an active END sequence
block specified by the "SET(OPTION) END=" statement, it
is executed before passing control to the first statement
of a command sequence or returning to command mode. The
list register is reset before repeating a command
sequence.
SORT Sorts any data generated by an output verb within the
command sequence. Entering a "]" from other than the
first prompt returns the user to the first prompt of the
current command or subcommand.
TPRINT Directs a line-printer-formatted display to the user's
terminal.
The command string "DISPLAY COMPANY" causes a number of companies to be
listed on the terminal. The user can enter the command:
PRINT SORT DISPLAY COMPANY
This command produces a sorted list of companies on the line printer.
Transact can also accept match selection criteria if the command sequence
contains a PROMPT(MATCH) or a DATA(MATCH) statement. For example:
PRINT SORT DISPLAY COMPANY = DE^
This command produces on the line printer a sorted list of all company
names beginning with the letters "DE". (See "MATCH Specification
Characters" later in this chapter, for an explanation of the character
"^".)
The REPEAT option could be added to this command string:
REPEAT PRINT SORT DISPLAY COMPANY = DE^, G^
The command now produces on the line printer a sorted list of all company
names beginning with "DE" and a sorted list of all those beginning with
"G".
The REPEAT option can be useful with commands that perform data entry.
The command REPEAT ADD TIME-SHEET causes the command sequence to repeat
until the user enters a terminating character.
Using FIELD accomplishes the same purpose as SET(OPTION) FIELD="><". It
causes the field length of a prompted-for data item to be displayed. For
example:
NAME> <
or
COMPANY> <
MPE/iX 5.0 Documentation