[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP COBOL
Reference Manual


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.)

Syntax Rules

  1. A space, left parenthesis, or pseudo-text delimiter (==) must immediately precede the opening character X (or x).
  2. The closing quotation mark or apostrophe must be immediately followed by one of the following:
    • Space
    • Comma
    • Semicolon
    • Period
    • Right parenthesis
    • Pseudo-text delimiter

Table 1-7 provides examples of hexadecimal literals.

Table 1-7 Hexadecimal Literals
Literal Value
X"00" NUL
x"0D" CR
x"2424" $$
X'7b7a' {z

National Literals

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.

Table 1-8 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.

03 DEF PIC X(6) 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

"abcd"
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.)

1The reserved word ALL, not followed by a literal, can be a subscript of an identifier that is a function argument. (The function must allow a variable number of arguments in this argument position; see Chapter 7.)

When a figurative constant represents a string of one or more characters, the string's length depends on its context:

  • The string's length can vary for a figurative constant in a VALUE IS clause, or for one associated with another data item (for example, when the figurative constant is moved to or compared with another data item). Proceeding from left to right, the compiler repeats the string of characters that represents the figurative constant. It repeats them, character by character, until the size of the resultant string equals that of the associated data item. This is done before and independent of the application of any JUSTIFIED clause specified for the data item.
  • When a figurative constant is not associated with another data item (for example, when it is in a DISPLAY, STRING, STOP, or UNSTRING statement), the length of the string is one occurrence of the ALL literal or one character in all other cases.

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.

Table 1-9 Separators
Separator Usage Rules
Space The space can be a separator or part of a separator.
  • Where a space is used as a separator or part of a separator, more than one space can be used.
  • A space can immediately precede any separator except:
    • As specified by the rules for reference formats (see Section 1.3)
    • The closing quotation mark of a nonnumeric literal; the space is then considered part of the nonnumeric literal rather than a separator
  • A space can immediately follow any separator except the opening quotation mark of a nonnumeric literal. After an opening quotation mark, the space is considered part of the nonnumeric literal rather than 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:
  • Subscripts
  • Indexes
  • Arithmetic expressions
  • Conditions
  • Reference modification
  • Boolean expressions
  • Intrinsic function argument lists
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