HP 3000 Manuals

Command Mode [ Getting Started With TRANSACT V ] MPE/iX 5.0 Documentation


Getting Started With TRANSACT V

Command Mode 

Much of the control of a program can be removed altogether from the
program logic and put into the hands of the user via built-in commands.
The following program illustrates a way to build the functions of adding,
updating, and reporting customer data into a program.
_________________________________________________________
|                                                       |
|      1     system ex18,base=orders;                   |
|      2                                                |
|      3     $$help:                                    |
|      4       display "List of customer transactions:";|
|      5       set(command) command;                    |
|      6                                                |
|      7     $$add:                                     |
|      8       set(delimiter) "/";                      |
|      9       prompt cust-no,checknot=customer;        |
|     10       prompt name:                             |
|     11              street-addr:                      |
|     12              city-state:                       |
|     13              zipcode;                          |
|     14       put customer;                            |
|     15                                                |
|     16     $$update:                                  |
|     17       set(delimiter) "/";                      |
|     18       list(auto) customer;                     |
|     19       data cust-no,check=customer;             |
|     20       get(current) customer;                   |
|     21       display;                                 |
|     22       data(set) name:                          |
|     23                 street-addr:                   |
|     24                 city-state:                    |
|     25                 zipcode;                       |
|     26       update customer;                         |
|     27                                                |
|     28     $$display:                                 |
|     29       list(auto) customer;                     |
|     30       data cust-no;                            |
|     31       set(key) list (cust-no);                 |
|     32       output customer;                         |
_________________________________________________________

          Figure 2-19.  Program using command mode for add, update, and display 

3       A command is identified to Transact by the special characters
        "$$" .  In our program we have identified four commands.  These
        are:  HELP, ADD, UPDATE, and DISPLAY.

        We can think of commands as entry points into a program.
        Typically a command will do a unit of work or a transaction.

        We do not need to do anything special to identify the end of a
        command sequence.  During the processing flow, when Transact
        detects the starting point of a new command, it returns control
        to the user and reissues the prompt > for the user to specify a
        new command or transaction.

        Command processing removes a lot of the control over processing
        flow from the program and puts it in the Transact processor.

5       SET(COMMAND) sets up a mini help system within the program.  If
        the user types HELP, we display the valid commands for this
        program.  Transact also does this automatically if the user types
        in the special command COMMAND.

The following example shows the execution of this program.
_______________________________________________________________________
|                                                                     |
|     > help                                                          |
|       List of customer transactions:                                |
|               HELP                                                  |
|               ADD                                                   |
|               UPDATE                                                |
|                                                                     |
|                                                                     |
|     > add                                                           |
|                                                                     |
|     CUST-NO> 401                                                    |
|     NAME> Brown Publishing                                          |
|     STREET-ADDR> 123 Wrong Street                                   |
|     CITY-STATE> Reno, Nevada                                        |
|     ZIPCODE> 36745                                                  |
|                                                                     |
|     > update                                                        |
|                                                                     |
|     CUST-NO> 401                                                    |
|     CUST-NO: NAME:                STREET-ADDR:         CITY-STATE:  |
|        ZIPCODE:                                                     |
|      401      Brown Publishing     123 Wrong Street     Reno, Nevada|
|         36745                                                       |
|     NAME>                                                           |
|     STREET-ADDR> 123 Right Street                                   |
|     CITY-STATE>                                                     |
|     ZIPCODE>                                                        |
|                                                                     |
|     >repeat display                                                 |
|                                                                     |
|     CUST-NO> 401                                                    |
|     CUST-NO: NAME:                STREET-ADDR:         CITY-STATE:  |
|        ZIPCODE:                                                     |
|      401      Brown Publishing     123 Right Street     Reno, Nevada|
|         36745                                                       |
|                                                                     |
|     CUST-NO> 1                                                      |
|     CUST-NO: NAME:                STREET-ADDR:         CITY-STATE:  |
|        ZIPCODE:                                                     |
|      1        Able-1 Answering     2775 Park Av         San Jose, Ca|
|         95111                                                       |
|                                                                     |
|     CUST-NO> ]                                                      |
|                                                                     |
|     > exit                                                          |
|                                                                     |
|     END OF PROGRAM                                                  |
|     :                                                               |
_______________________________________________________________________

          Figure 2-20.  Command mode interaction 

The user merely types in the command to be executed.  After Transact
finishes the transaction, it prompts for the next command.

The user can cause a command to be iterative by prefacing the command
with the special command REPEAT as in REPEAT DISPLAY, where DISPLAY is
one of the commands in our program.

We can add one additional level of commands to our program, called a
subcommand.  For example, we want to have the general facilities to ADD,
UPDATE, and DISPLAY in our program.  But within each we want to build
specific transactions such as adding customers, adding part numbers, etc.

These subcommands are identified to Transact by the special character "$"
.  Sub-commands must be placed after the command they apply to and are
executed by the user by typing in both the command and subcommand names.
The following program and sample execution demonstrate this.
___________________________________________________
|                                                 |
|      1     system ex19,base=orders;             |
|      2                                          |
|      3     $$help:                              |
|      4       display "List of transactions:";   |
|      5       set(command) command;              |
|      6                                          |
|      7     $$add:                               |
|      8     $help:                               |
|      9      display "types of add maintenance:";|
|     10      set(command) command(add);          |
|     11     $customer:                           |
|     12       set(delimiter) "/";                |
|     13       prompt cust-no,checknot=customer;  |
|     14       prompt name:                       |
|     15              street-addr:                |
|     16              city-state:                 |
|     17              zipcode;                    |
|     18       put customer;                      |
|     19                                          |
|     20     $parts:                              |
|     21     set(delimiter) "/";                  |
|     22     prompt part-number,checknot=parts;   |
|     23     prompt description;                  |
|     24     put parts;                           |
|     25                                          |
|     26                                          |
|     27     $$update:                            |
|     28       set(delimiter) "/";                |
|     29       list(auto) customer;               |
|     30       data cust-no,check=customer;       |
|     31       get(current) customer;             |
|     32       display;                           |
|     33       data(set) name:                    |
|     34                 street-addr:             |
|     35                 city-state:              |
|     36                 zipcode;                 |
|     37       update customer;                   |
|     38                                          |
|     39     $$display:                           |
|     40       list(auto) customer;               |
|     41       data cust-no;                      |
|     42       set(key) list (cust-no);           |
|     43       output customer;                   |
___________________________________________________

          Figure 2-21.  Program with subcommands 
_____________________________________
|                                   |
|     > help                        |
|     List of transactions:         |
|                                   |
|               HELP                |
|               ADD                 |
|               UPDATE              |
|               DISPLAY             |
|                                   |
|     > add help                    |
|     types of add maintenance:     |
|                                   |
|               HELP                |
|               CUSTOMER            |
|               PARTS               |
|                                   |
|     > add parts                   |
|     PART-NUMBER> p001             |
|     DESCRIPTION> air socket       |
|                                   |
|     > add customer                |
|     CUST-NO> 501                  |
|     NAME> Foot Appeal             |
|     STREET-ADDR> 323 Bottom Ave.  |
|     CITY-STATE> Atlanta, Ga.      |
|     ZIPCODE> 23845                |
|                                   |
|     >                             |
_____________________________________

          Figure 2-22.  User interaction with subcommands 


MPE/iX 5.0 Documentation