HP 3000 Manuals

ANSI85 Features in the ENVIRONMENT DIVISION [ HP COBOL II/XL Programmer's Guide ] MPE/iX 5.0 Documentation


HP COBOL II/XL Programmer's Guide

ANSI85 Features in the ENVIRONMENT DIVISION 

The ENVIRONMENT DIVISION has two ANSI85 features:

   *   CLASS clause.
   *   SYMBOLIC CHARACTERS clause.

Both are in the SPECIAL-NAMES paragraph.


NOTE The SPECIAL-NAMES paragraph (in the ENVIRONMENT DIVISION) cannot appear in nested programs. All items in the SPECIAL-NAMES paragraph are implicitly global.
CLASS Clause The CLASS clause is in the SPECIAL-NAMES paragraph of the ENVIRONMENT DIVISION. It defines a class for use in a class condition in the PROCEDURE DIVISION. (The CLASS clause allows a user-defined class, in addition to the pre-existing ALPHABETIC and NUMERIC classes.) Example. The following shows an example of the CLASS clause defining a class VALID-GRADE: SPECIAL-NAMES. CLASS VALID-GRADE IS "A" "B" "C" "D" "F". The following example shows how the class VALID-GRADE could be used:[REV BEG] WORKING-STORAGE SECTION. 01 GRADE-LIST. 05 CLASS-GRADES PIC X OCCURS 7 TIMES. : IF GRADE-LIST IS NOT VALID-GRADE THEN PERFORM ERROR-ROUTINE. [REV END] The above IF statement will perform ERROR-ROUTINE if GRADE-LIST contains a character other than A, B, C, D, or F. SYMBOLIC CHARACTERS Clause The SYMBOLIC CHARACTERS clause is in the SPECIAL-NAMES paragraph of the ENVIRONMENT DIVISION. It equates names with ASCII character numbers, creating figurative constants. You can use it to name and refer to characters whose ASCII values are in the range 1..256. It is especially useful for referencing unprintable characters. Example. The following shows the SYMBOLIC CHARACTERS clause: SYMBOLIC CHARACTERS BELL IS 8, CARRIAGE-RETURN IS 14. The above statement in the SPECIAL-NAMES paragraph of the ENVIRONMENT DIVISION equates the names BELL and CARRIAGE-RETURN with the unprintable characters for the bell (ASCII character number 8) and carriage return (ASCII character number 14). In your program, you can refer to these characters by the names BELL and CARRIAGE-RETURN, as in the following statement: DISPLAY BELL "JOB COMPLETED" CARRIAGE-RETURN.
NOTE The first character of the COBOL character set is one, not zero. The COBOL characters in the preceding example and their binary, octal, decimal, and hexadecimal representations are:
----------------------------------------------------------------------------------------------------- | | | | | | | COBOL | Binary | Octal | Decimal | Hexadecimal | | Character | Representation | Representation | Representation | Representation | | | | | | | ----------------------------------------------------------------------------------------------------- | | | | | | | 8 | 0111 | 7 | 7 | 7 | | | | | | | ----------------------------------------------------------------------------------------------------- | | | | | | | 14 | 1101 | 15 | 13 | D | | | | | | | -----------------------------------------------------------------------------------------------------


MPE/iX 5.0 Documentation