In this topic, we have explained about the below sections -
What is the COBOL word?
A COBOL word is a set of characters that forms a user-defined word, a system-name, or a reserved word. COBOL word maximum size is 30 characters.
Each character of a COBOL word is selected from the following set except for arithmetic operators and relational characters -
- Latin uppercase letters A through Z
- Latin lowercase letters a through z
- digits 0 through 9
- - (hyphen)
- _ (underscore)
Each lowercase single-byte alphabetic letter is equivalent to its single-byte uppercase alphabetic letter in COBOL words. For example - "a" is equal to "A".
What are the Rules for all COBOL words?
Programmer should follow the below guidelines while forming COBOL words -
- The hyphen or underscore cannot appear as the first or last character. For example - -WS, WS-, _WS, WS_ are invalid.
- Most user-defined words must contain at least one alphabetic character except section-names, paragraph-names, priority-numbers, and level-numbers. For example - A123, W-12, 1W2, 12W etc,.
- A reserved word cannot be used as a user-defined word or a system-name. For example - ZERO, MOVE, IF, ELSE etc, are invalid as user-defined words.
- The same COBOL word can use as both a user-defined word and a system-name depending on the context.
COBOL word types -
COBOL words are 5 types and those are -
|COBOL word type||Description|
|User-defined words||A COBOL word can be a user-defined that should be supplied by the user to fulfill the format of a clause or statement. The user-defined word maximum length is 30 bytes except level-numbers and priority-numbers.|
|System-names||A system-name is a character string that has a detailed meaning to the system. There are three types of system-names -
|Function-names||A function-name specifies the mechanism to determine an intrinsic function value. The same word can appear in a program as a user-defined word or a system-name in a different context.|
|Context-sensitive words||A context-sensitive word is formed according to rules for reserved words, and may be used as a function-name, a user-defined word, or a system-name.|
|Reserved words||A reserved word is a set of characters that is defined with a predefined meaning in a COBOL source unit.|
The below list shows the examples for each type of word -
|Word Type||Some Examples|
CHAR LENGTH MIN MAX SQRT ...
APPEND DAYS DEFAULT HOURS MICROSECONDS MINUTES MONTHS SECONDS SYMMBOL TIMSTAMP YEARS YYYYDDD YYYYMMDD ...
MOVE IF ELSE PERFORM ACCEPT DISPLAY ...