HP 3000 Manuals

Statements [ HP Transact Reference Manual ] MPE/iX 5.0 Documentation


HP Transact Reference Manual

Statements 

Statements perform a Transact program's data processing functions.  The
general format for a Transact statement is:

     [label:] verb[(modifier)] [target][,option-list];

These statement parts are described below, followed by a discussion of
compound statements and statement formatting.  Other statement parts,
including relational and arithmetic operators, are listed with the verbs
to which they apply.  A statement is always terminated by a semicolon.
(Rules for punctuating statements are discussed in Table 2-1.)

Labels 

Statement labels help to control program flow.  They identify the point
to which a conditional or unconditional statement should branch.  A
statement label can be up to 32 characters long, and it must begin with
an alphabetic character.  It is followed by a colon and one or more
Transact statements.  The program shown in Figure 2-1 illustrates the
statement label PRINT-IT.

Verbs 

Transact verbs are the heart of Transact statements.  They are the action
words for any procedure.  Verbs in Figure 2-1 include LIST, DATA, FIND,
REPEAT, DISPLAY, RESET, INPUT, EXIT, SYSTEM, DEFINE, RETURN, and END.
Transact verbs are described in detail in Chapter 8.

Modifiers 

Modifiers that change or enhance a verb's action are an integral part of
the verb.  Some modifiers specify how values entered by the user are
used.  Other modifiers describe a file access method.  Modifiers are
always enclosed within parentheses and must NOT be separated from the
preceding verb by a space.  For example:

       FIND(CHAIN) DET;    is correct 
       FIND (CHAIN) DET;   is NOT correct 

In Figure 2-1, the verb FIND(SERIAL) has a different function with the
modifier SERIAL than it has as FIND without a modifier.  See Chapter 8
for further information on the modifiers for each verb.

Target 

The target identifies the program variable upon which the verb action is
performed.  It can also identify the file or database for a file
operation.  Targets used in Figure 2-1 include the KSAM file ORDER and
the data item CUST-NAME.

Option-List 

A list of one or more options, separated by commas, can be specified with
certain verbs to enhance their action.  Some options tell how information
should be formatted, while others suppress regular processor operations.
Examples of option-list options in Figure 2-1 are PERFORM and
LIST=(CUST-NAME:AMOUNT-DUE).

The verbs that allow options also have a target; options always follow
the verb's target and are separated from the target by a comma.  Some
verbs allow you to specify more than one target/option-list combination
by separating them with a colon, as follows:

     verb(modifier)
          target1, option-list1:
          target2, option-list2:
           .
           .
          targetn, option-listn;

The verbs that allow such multiple target/option lists include DEFINE,
DISPLAY, DATA, LIST, and PROMPT; multiple target/option lists are not
allowed with database or file access verbs.  The DISPLAY statement in
Figure 2-1 has multiple target/option lists.

Compound Statements 

You can combine several Transact statements to form a compound statement.
These can be either unconditional or conditional.  All compound
statements are bracketed between a pair of DO...DOEND statements.
Compound statements also can be nested.  The following example shows an
unconditional compound statement:

     DO

        PROMPT(MATCH) CUST-NO;

        LIST NAME:
             ADDRESS:
             CITY:
             ZIP;

        OUTPUT MASTER, LIST=(CUST-NO:ZIP);

     DOEND;

The next example shows a conditional compound statement.

     IF (A) = (B) THEN

       DO
          LET (A) = (A) * (D);
          LET (B) = (B) * (X);
       DOEND

     ELSE

       DO
          LET (A) = (A) * (C);
          LET (B) = (B) * (Z);
       DOEND;

The example in Figure 2-1 has a compound statement.  Other examples of
compound statements can be found in the IF verb description in Chapter 8
and in the "Compiler Listings" section in Chapter 9.

In the example immediately above, note that the first DOEND does not have
the semicolon (;) delimiter; the delimiter is used to end the entire
compound statement.  Individual statements between the DO...DOEND pairs
are terminated with a semicolon.

DOEND always requires a semicolon except under two circumstances:  (1)
just before ELSE, or (2) just before UNTIL in a REPEAT statement.

Statement Formatting 

A Transact source program contains program text in 72-column records (not
including line numbers).  Program text can be entered in free format, but
good programming practice suggests that you use a paragraph and an
indented structure.  In general, you can read and modify code more easily
if you break the code into separate lines for labels, verbs, and options,
and use indentation freely.  You can break lines of code in any place
except in the middle of a word.  Thus, the following two statements would
have the same effect:

     MOVE (A)=(B);        and        MOVE (A)=
                                       (B);

Note that the second line can start anywhere and no continuation
indicator is required.  Words, however, cannot be split, and modifiers
cannot be separated from their verbs.  The following statements are
illegal:

         MO                      and               FIND
         VE (A)=(B);                              (CHAIN)

     (verbs cannot be split)                (verb(modifier) is
                                        considered a single word)

If a string within quotes is split between lines, it must become two
quoted strings.

     DISPLAY "THIS IS A"
     " TEST";



MPE/iX 5.0 Documentation