Literals [ COBOL/HP-UX Language Reference for the Series 700 and 800 ] MPE/iX 5.0 Documentation
COBOL/HP-UX Language Reference for the Series 700 and 800
Literals
(VSC2) (MF)
DBCS Literals
There is a third type of literal in addition to the nonnumeric and
numeric literals described in the chapter COBOL Concepts, the DBCS
literal.
A DBCS literal is a character-string delimited at both ends by quotation
marks or apostrophes, with the beginning delimiter preceded by a "G". It
can consist of any characters in the computer's DBCS character set. It
can be up to 28 DBCS characters in length. It cannot be continued across
lines.
Whether quotation marks or apostrophes are used, the presence of that
delimiter within a DBCS literal can be represented by two contiguous
occurrences. The presence of the character that is not serving as the
delimiter is represented by a single occurrence. The value of a DBCS
literal in the object program is the string of characters itself, except:
1. The initial G and the delimiters are excluded, and
2. Each embedded pair of contiguous delimiter characters represents a
single character.
Category of DBCS Literals.
All DBCS literals can be used wherever nonnumeric literals can be used,
subject to rules and exceptions given in the appropriate places in this
chapter.
Mixed Literals
DBCS characters can be included in nonnumeric literals. A nonnumeric
literal that includes DBCS characters is called a mixed literal. In such
a literal, SBCS characters are represented by SBCS codes and DBCS
characters by DBCS codes. Each space character is represented by the
SBCS code for space.
On output both the SBCS and the DBCS codes will be recognized. The first
byte of a DBCS code is never a valid SBCS code; hence the two can be used
together without confusion. But in operations within the program the
literal will be treated as an ordinary nonnumeric literal. It is the
programmer's responsibility to ensure that the two halves of a DBCS code
do not get separated.
A nonnumeric literal is of category alphanumeric, not DBCS, regardless of
whether it includes DBCS characters.
A mixed literal cannot be continued across lines.
________________________________________________________________________
|(MF) This restriction has been removed. |
________________________________________________________________________
Figurative Constants
(VSC2) (MF)
If a figurative constant is used where only a DBCS literal is allowed
(according to the rules concerning classes and categories given in the
appropriate places in this chapter), it is a DBCS literal. Each space in
this literal is a DBCS space.
Only the figurative constant SPACE(S) can be a DBCS literal.
The "N" literal
Another format of literal, equivalent to the DBCS literal, is used in the
MIA COBOL specification.
General Format
N"DBCS-character-1..."
Syntax Rules
1. An N-literal can contain no more than 18 DBCS-characters, and can
not be split over two lines.
2. An N-literal can contain only double-byte characters for your
computer's Double Byte Character Set.
3. When single- and double-bytes are made to equate, any double-byte
quotation marks used in the literal should be written twice. For
example, in order to express a single-byte quotation mark in the
literal, you should write:
N"ABC""DEF"
4. N-literal specification and behavior can be modified in exactly
the same way as G-literals using the APOST directive to replace a
double-character by an apostrophe character.
General Rules
1. The N-literal can be used in conjunction with ALL to make a
figurative constant (see the chapter COBOL Concepts).
2. All characters must be double-byte characters.
MPE/iX 5.0 Documentation