The CLASS clause assigns names (class names) to arbitrary character sets.
The defined class names can be used in conditional expressions.
000010 @OPTIONS MAIN 000020*---------------------------------------------------------------------- 000030* In this sample, the CLASS clause is used to determine the validity 000035* of the input data. 000040*---------------------------------------------------------------------- 000050 IDENTIFICATION DIVISION. 000060 PROGRAM-ID. SAMPLE. 000070 ENVIRONMENT DIVISION. 000080 CONFIGURATION SECTION. 000090*---------------------------------------------------------------------- 000100* The class names of hexadecimal character scope are defined. 000110*---------------------------------------------------------------------- 000120 SPECIAL-NAMES. 000130 CLASS HEX IS "0" THRU "9" 000140 "A" THRU "F" 000145 "a" THRU "f". 000150*---------------------------------------------------------------------- 000160 DATA DIVISION. 000170 WORKING-STORAGE SECTION. 000180 01 IN-DATA PIC X(4). 000190 PROCEDURE DIVISION. 000200 DISPLAY "Please input hexadecimal data (4 digits). >>" WITH NO 000205 ADVANCING. 000210 ACCEPT IN-DATA FROM CONSOLE. 000220*---------------------------------------------------------------------- 000230* The defined class-names can be used in conditional expressions. 000240*---------------------------------------------------------------------- 000250 IF IN-DATA IS HEX THEN 000260 DISPLAY "The hexadecimal value is correct." 000270 ELSE 000280 DISPLAY "The input data is incorrect." 000290 END-IF 000300*---------------------------------------------------------------------- 000310 END PROGRAM SAMPLE.