[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP COBOL
Reference Manual


Previous Contents Index


EVALUATE LOW-STOK  WEEK-USE  LOC-VNDR ON-ORDER
  WHEN   "Y",    16 THRU 999,  ANY,   "N" GO TO RUSH-ORDER
  WHEN   "Y",    16 THRU 999,  ANY,   "Y" GO TO NORMAL-ORDER
  WHEN   "Y",     8 THRU 15,   "N",   "N" GO TO RUSH-ORDER
  WHEN   "Y",     8 THRU 15,   "N",   "Y" GO TO NORMAL-ORDER
  WHEN   "Y",     8 THRU 15,   "Y",   "N" GO TO NORMAL-ORDER
  WHEN   "Y",     0 THRU 7,    ANY,   "N" GO TO NORMAL-ORDER
  WHEN   "N",       ANY,       ANY,   "Y" GO TO CANCEL-ORDER
  END-EVALUATE.

Samples:
LOW-STOK WEEK-USE LOC-VNDR ON-ORDER Result
"Y" 38 "N" "Y" NORMAL-ORDER
"N" 20 "Y" "Y" CANCEL-ORDER
"N" 12 "Y" "N" next statement
"Y" 12 "Y" "N" NORMAL-ORDER
"Y" 12 "Y" "Y" next statement
"Y" 40 "N" "N" RUSH-ORDER
  • Relation conditions and arithmetic expressions.


    EVALUATE-ITEM-ROUTINE.
    *
    * After the imperative statement in the selected WHEN phrase
    * executes (for example PERFORM PROC-A), control then
    * transfers to the first statement following the end of the
    * EVALUATE statement (MOVE A TO B).
    *
    
       EVALUATE ITEMA > 6 AND < 30, 8 * ITEMB - 1
          WHEN   TRUE,              5 * ITEMC     PERFORM PROC-A
          WHEN   FALSE,             ITEMC         PERFORM PROC-B
          WHEN   ITEMC > 12,        -1            PERFORM PROC-C
          WHEN   TRUE,              NOT 7 THRU 40 PERFORM PROC-D
          WHEN   OTHER                            PERFORM PROC-E
       END-EVALUATE.
       MOVE A TO B.
    

    Samples:
    ITEMA ITEMB ITEMC Result
    12 2 3 PROC-A
    25 0 14 PROC-C
    30 0 14 PROC-E
    6 3 23 PROC-B
    14 0 5 PROC-D
    5 0 11 PROC-C

    Consider how the EVALUATE statement works using the values in the previous sample:

    1. The value of the first subject is a truth value (General Rule 1e). ITEMA is not greater than 6 and less than 30; therefore, the value of the first subject is false.
    2. The value of the second subject is a numeric value (General Rule 1d):
      8 * 0-1 = -1.
    3. When the first WHEN phrase is evaluated:
      • The value of the first object is a truth value (General Rule 1f): true.
      • The value of the second object is a numeric value: 55.
      • The value of the first object does not equal that of the first subject. Furthermore, the values of the second object and subject do not match. Therefore, this WHEN phrase is not selected (General Rule 5).
    4. When the second WHEN phrase is evaluated:
      • The value of the first object is a truth value (General Rule 1f): false.
      • The value of the second object is a numeric value: 11.
      • The value of the first object equals that of the first subject. However, the values of the second object and subject do not match. Therefore, this WHEN phrase is not selected (General Rule 5).
    5. When the third WHEN phrase is evaluated:
      • The value of the first object is a truth value (General Rule 1f). Because the value of ITEMC is not greater than 12, the value of this object is false.
      • The value of the second object is a numeric value: -1.
      • The value of the first object equals that of the first subject. The values of the second object and subject also match. Therefore, this WHEN phrase is selected (General Rule 4).
    6. The statement following the third WHEN phrase is PERFORM PROC-C. Control transfers to that procedure, and the EVALUATE statement ends.

    6.8.13 EXIT

    Function

    The EXIT statement provides a common logical end point for a series of procedures.


    Syntax Rule

    The EXIT statement must appear in a sentence by itself and be the only sentence in the paragraph.

    General Rule

    The EXIT statement associates a procedure-name with a point in the program. It has no other effect on program compilation or execution.

    Example


    REPORT-INVALID-ADD.
        DISPLAY " ".
        DISPLAY "INVALID ADDITION".
        DISPLAY "RECORD ALREADY EXISTS".
        DISPLAY "UPDATE ATTEMPT: " UPDATE-REC.
        DISPLAY "EXISTING RECORD: " OLD-REC.
    REPORT-INVALID-ADD-EXIT.
        EXIT.
    

    6.8.14 EXIT PROGRAM

    Function

    The EXIT PROGRAM statement marks the logical end of a called program.


    Syntax Rules

    1. If the EXIT PROGRAM statement is in a consecutive sequence of imperative statements, it must be the last statement in that sequence.
    2. The EXIT PROGRAM statement cannot appear in a GLOBAL USE procedure.

    General Rules

    1. If EXIT PROGRAM executes in a program that is not a called program, it causes execution to continue with the next executable statement. Refer to the HP COBOL User Manual for information on how the v3 setting of the standard compiler option affects the EXIT PROGRAM statement.
    2. If the EXIT PROGRAM statement executes in a called program without the INITIAL clause in its PROGRAM-ID paragraph, execution continues with the next executable statement after the CALL statement in the calling program.
      The state of the calling program does not change; it is the same as when the program executed the CALL statement. However, the contents of data items and the positioning of data files shared by the calling and called programs can change.
      The state of the called program does not change. However, the called program is considered to have reached the ends of the ranges of all PERFORM statements it executed. Therefore, an error does not occur if the called program is entered again during image execution.
    3. When EXIT PROGRAM executes in a called program with the INITIAL attribute, the actions described in General Rule 2 also apply. In addition, executing the EXIT PROGRAM statement is equivalent to executing a CANCEL statement that names the called program.
    4. Special handling of the EXIT PROGRAM statement is performed when you specify the standard compiler option with the v3 setting on the compiler command line. Refer to the HP COBOL User Manual for more information.

    Example


    TEST-RETURN.
        IF ITEMA NOT = ITEMB
             MOVE ITEMA TO ITEMB
             EXIT PROGRAM.
    


    Previous Next Contents Index