[an error occurred while processing this directive]
HP OpenVMS Systems Documentation |
HP COBOL
|
Previous | Contents | Index |
03 HEX_VAL PIC X VALUE X"00". |
The character string consists only of pairs of hexadecimal digits representing a byte value ranging from 00 to FF; hence, only the characters 0 to 9, A to F, and a to f are valid.
The value of a hexadecimal literal is the composite value of the paired hexadecimal representations. The compiler truncates hexadecimal literals to a maximum of 128 hexadecimal representations (pairs of hexadecimal digits).
A hexadecimal literal can be used interchangeably wherever a nonnumeric literal can appear in HP COBOL syntax. (Thus, hexadecimal literals cannot be used as operands in arithmetic statements.)
Table 1-7 provides examples of hexadecimal literals.
Literal | Value |
---|---|
X"00" | NUL |
x"0D" | CR |
x"2424" | $$ |
X'7b7a' | {z |
National literals can be from 0 to 128 2-byte characters (hence 256 bytes). The syntax is:
VALUE N"". |
National literals are made available when /NATIONALITY=JAPAN or -nationality japan is specified.
1.2.3 Figurative Constants
Figurative constants name and refer to specific
constant values generated by the compiler. The singular and plural
forms of figurative constants are equivalent and interchangeable.
Table 1-8 lists the figurative constants.
Figurative Constant | Value |
---|---|
ZERO, ZEROS, ZEROES |
Represent the value zero, or one or more occurrences of the character 0
from the computer character set, depending on context. In the following
example, the first use of the word ZERO represents a zero value; the
second represents six 0 characters:
03 ABC PIC 9(5) VALUE ZERO. |
SPACE, SPACES | Represent one or more space characters from the computer character set. |
HIGH-VALUE,
HIGH-VALUES |
Represent one or more occurrences of the character with the highest
ordinal position in the program collating sequence. For example,
HIGH-VALUE for the native collating sequence is hexadecimal FF.
The value of HIGH-VALUE depends on the collating sequence specified by clauses in the OBJECT-COMPUTER and SPECIAL-NAMES paragraphs. For example, if the program collating sequence is ASCII, HIGH-VALUE is hexadecimal 7F (hexadecimal FF for EBCDIC). For more information, see Section 4.1.2 and Section 4.1.3 sections in Chapter 4, Environment Division. |
LOW-VALUE,
LOW-VALUES |
Represent one or more occurrences of the character with the lowest
ordinal position in the program collating sequence (hexadecimal 00 for
the native collating sequence).
The value of LOW-VALUE depends on the program collating sequence specified by clauses in the OBJECT-COMPUTER and SPECIAL-NAMES paragraphs. For more information, see the Section 4.1.2 and Section 4.1.3 sections in Chapter 4, Environment Division. |
QUOTE, QUOTES |
Represent one or more occurrences of the quotation mark character.
QUOTE or QUOTES cannot be used in place of a quotation mark to bound a
nonnumeric literal. The following examples are not equivalent:
QUOTE abcd QUOTE |
ALL Literal | Represents one or more occurrences of the string of characters making up the literal. The literal must be either nonnumeric, a symbolic-character, or a figurative constant other than ALL literal. For a figurative constant, the word ALL is redundant and serves only to enhance readability. 1 |
Symbolic-character | Represents one or more occurrences of the character specified as the value of symbolic-character. (See Section 4.1.3 in Chapter 4, Environment Division.) |
When a figurative constant represents a string of one or more characters, the string's length depends on its context:
A figurative constant is valid wherever the word literal (or its abbreviation, "lit") appears in a general format or its associated rules. However, ZERO (ZEROS or ZEROES, plural) is the only valid figurative constant for literals restricted to numeric characters.
The actual characters associated with HIGH-VALUE, HIGH-VALUES,
LOW-VALUE, and LOW-VALUES depend on the program collating sequence. For
more information, see Section 4.1.2 and Section 4.1.3 in Chapter 4, Environment Division.
1.2.4 PICTURE Character-Strings
A PICTURE character-string defines the size and category of an elementary data item. It can consist of the currency symbol ($) and certain combinations of characters in the COBOL character set. (See Section 5.3.37.)
A punctuation character that is part of a PICTURE character-string is
not considered to be a punctuation character. Instead, the compiler
treats it as a symbol within the PICTURE character-string.
1.2.5 Separators
A separator delimits character-strings. It can be one character or two contiguous characters formed according to the rules in Table 1-9.
Separator | Usage Rules |
---|---|
Space |
The space can be a separator or part of a separator.
|
Comma and Semicolon | The comma and semicolon are separators when they immediately precede a space. In this case, the comma and semicolon are interchangeable with each other and with the separator space. They can be used anywhere in a source program that a separator space can be used. |
Period |
The period is a separator when it immediately
precedes a space or a return character. It can be used only where
allowed by:
|
Parentheses |
Parentheses can be used only in balanced pairs
of left and right parentheses to delimit:
|
Quotation Marks
Apostrophes |
An opening quotation mark or apostrophe must be immediately preceded by a separator space or a left parenthesis. A closing quotation mark (") or apostrophe (') must be immediately followed by one of the separators: space, comma, semicolon, period, or right parenthesis. |
Horizontal Tab | The horizontal tab aligns statements or clauses on successive columns of the source program listing. It is interchangeable with the separator space. When the compiler detects a tab character (other than in a nonnumeric literal), it generates one or more space characters consistent with the tab character position in the source line. (See Section 1.3.) |
Pseudo-Text
Delimiter |
The pseudo-text delimiter is two
contiguous equal signs (==), both of which must be on the same source
line. A space must immediately precede an opening pseudo-text
delimiter. One of the following separators must immediately follow a
closing pseudo-text delimiter: spaces, commas, semicolons, or periods.
Pseudo-text delimiters can be used only in balanced pairs. They delimit pseudo-text. (See Chapter 8.) |
Colon | The separator colon delimits operands in reference modification. It is required when shown in a general format. (See Section 6.2.3.) |
Previous | Next | Contents | Index |