Top
NetCOBOL V11.0 Syntax Samples
FUJITSU Software

1.33 Abbreviating Combined Relation Conditions

Combined relation conditions (multiple condition expressions) can be abbreviated if the left part or right part is the same. The source will be easier to read if combined relation conditions are abbreviated.

000010 @OPTIONS MAIN
000020*----------------------------------------------------------------------
000030* Combined relation conditions can be abbreviated depending on the 
000035* conditions.
000040*----------------------------------------------------------------------
000050 IDENTIFICATION   DIVISION.
000060 PROGRAM-ID.      SAMPLE.
000070 DATA             DIVISION.
000080 WORKING-STORAGE  SECTION.
000090 01 IN-DATA       PIC 9(1).
000100 01 COUNTER       PIC 9(1).
000110 CONSTANT         SECTION.
000120 01 SPORTS-DATA.
000130    02              PIC X(9) VALUE "Marathon".
000140    02              PIC X(9) VALUE "Baseball".
000150    02              PIC X(9) VALUE "Tennis".
000160    02              PIC X(9) VALUE "Skiing".
000170    02              PIC X(9) VALUE "Judo".
000180    02              PIC X(9) VALUE "Soccer".
000190 01              REDEFINES SPORTS-DATA.
000200    02 SPORTS       OCCURS 6 PIC X(9).
000210 PROCEDURE        DIVISION.
000220     PERFORM TEST BEFORE
000230             VARYING COUNTER FROM 1 BY 1 UNTIL COUNTER > 6
000240       DISPLAY COUNTER ". " SPORTS(COUNTER) WITH NO ADVANCING
000250     END-PERFORM.
000260     DISPLAY " ".
000270     DISPLAY " ".
000280     DISPLAY "Balls are used in which sport? >>" WITH NO ADVANCING.
000290     ACCEPT  IN-DATA.
000300     DISPLAY " ".
000310*----------------------------------------------------------------------
000320* Multiple condition expressions where the left part is the same but 
000330* the right part changes can be abbreviated as shown below:
000340* If abbreviation is not used, the condition expressions must be 
000350* written as shown below:
000360* IF IN-DATA = 2 OR
000370*    IN-DATA = 3 OR
000380*    IN-DATA = 6 THEN
000390*----------------------------------------------------------------------
000400     IF IN-DATA = 2 OR 3 OR 6 THEN
000410       DISPLAY "This is correct."
000420     ELSE
000430       DISPLAY "This is incorrect."
000440     END-IF.
000450*----------------------------------------------------------------------
000460 END PROGRAM SAMPLE.