COBOL Manual for TNS and TNS/R Programs
Language Elements
HP COBOL Manual for TNS and TNS/R Programs—522555-006
3-22
Literals
In general, you can use a figurative constant wherever the syntax rules of the language
require or permit a literal. The exceptions to this rule are:
•
When the literal must be a numeric literal, the only acceptable figurative constant
is [ALL] ZERO[[E]S] (which generates the numeric value 0). The other forms of
figurative constant always generate a nonnumeric value; therefore, such forms are
not acceptable when the context requires a numeric value.
•
There are certain contexts in which you cannot use figurative constants whose
source form includes the word ALL. When this is the case, the usage
considerations for that particular language element’s syntax mention the usage
restriction.
•
The COBOL language includes several constructs where a literal cannot be any
figurative constant. When this is the case, the usage considerations for that
particular language element’s syntax mention the usage restriction.
•
When SPACE, QUOTE, or ZERO is applied to a national data item, the class of the
figurative literal is national. The 2-byte value of the national character set that
corresponds to SPACE, QUOTE, or ZERO when the program is compiled is used.
For LOW-VALUES and HIGH-VALUES, the highest and lowest positions in the
collating sequence are assumed.
When a figurative constant represents a nonnumeric or national value, that value is a
string of one or more characters. The compiler determines the length of the string
according to these rules:
•
When you associate a figurative constant with a data item (for example, by moving
the figurative constant to the data item or by comparing them or using the figurative
constant in a VALUE clause), the compiler repeats the figurative constant value
character by character until its size equals or exceeds the size of the data item.
The compiler then truncates the resultant string from the right end until it has the
same number of character positions as the associated data item. This happens
prior to and independently of the application of any JUSTIFIED clause for the data
item.
•
When you use a figurative constant whose source form does not include the word
ALL with a DISPLAY, STRING, STOP, or UNSTRING statement, the compiler
generates exactly one character.
•
When you use a figurative constant whose source form does include the word ALL,
there are two possibilities:
°
If a nonnumeric or national literal follows the word ALL, the compiler generates
a string having the length and value of the literal.
°
If a nonnumeric or national literal does not follow the word ALL, the compiler
generates a string of exactly one instance of the character represented by the
reserved word (figurative constant) or the symbolic character that follows the
word ALL.
•
The length of a figurative constant in a concatenation expression is one.