Top
NetCOBOL V11.0 Syntax Samples
FUJITSU Software

1.21 VALUE Clause for Conditional Names

An 88 level can be used to assign a conditional name representing a particular value or values for a data item. The defined conditional name can be used in conditional expressions.

000010 @OPTIONS MAIN
000020*----------------------------------------------------------------------
000030* Level-number 88 items can be used to define conditional names when 
000040* data is declared.
000050*----------------------------------------------------------------------
000060 IDENTIFICATION     DIVISION.
000070 PROGRAM-ID.        SAMPLE.
000080 DATA               DIVISION.
000090 WORKING-STORAGE SECTION.
000100 01 TODAY.
000110    02              PIC 9(2).
000120*----------------------------------------------------------------------
000130* The conditional names are defined based on data item values.
000140*----------------------------------------------------------------------
000150    02 MONTH        PIC 9(2).
000160      88 SPRING-M   VALUE  3 THRU 5.
000170      88 SUMMER-M   VALUE  6 THRU 8.
000180      88 AUTUMN-M   VALUE  9 THRU 11.
000190      88 WINTER-M   VALUE 12, 1, 2.
000200*----------------------------------------------------------------------
000210    02              PIC 9(2).
000220 PROCEDURE          DIVISION.
000230      ACCEPT TODAY FROM DATE.
000240*----------------------------------------------------------------------
000250* The conditional names can be used in conditional expressions.
000260*----------------------------------------------------------------------
000270     EVALUATE TRUE
000280      WHEN SPRING-M
000290       DISPLAY "It is Spring.  Let's go hiking!!"
000300      WHEN SUMMER-M
000310       DISPLAY "It is Summer.  Let's go swimming!!"
000320      WHEN AUTUMN-M
000330       DISPLAY "It is Autumn.  Let's play tennis!!"
000340      WHEN WINTER-M
000350       DISPLAY "It is Winter.  Let's go skiing!!"
000360     END-EVALUATE.
000370*----------------------------------------------------------------------
000380 END PROGRAM SAMPLE.