1.1.4.1 Nonnumeric Literals
A nonnumeric literal is a character string enclosed in quotation marks
("), and can contain any allowable character from the character set of the
computer. The maximum length of a nonnumeric literal is 160 characters.
The enclosing quotation marks are excluded from the literal when the
program is compiled. An embedded quotation mark must be represented by a
pair of quotation marks (""). For example,
"THIS ISN""T WRONG"
X As an IBM extension, you can use apostrophes as the literal delimiters
X instead of quotes (independent of the APOST/QUOTE compiler option). An
X embedded apostrophe must be represented by a pair of apostrophes ('').
X For example,
X 'THIS ISN''T WRONG'
The delimiter character used as the opening delimiter for a literal must
be used as the closing delimiter for that literal. For example,
X 'THIS IS RIGHT'
"THIS IS RIGHT"
'THIS IS WRONG"
Any punctuation characters included within a nonnumeric literal are part
of the value of the literal.
Every nonnumeric literal is in the alphanumeric data category. (Data
categories are described in "Classes and Categories of Data" in
topic 5.1.6.5.)
X Table 4 lists when nonnumeric literals with double-byte or multiple-byte
X characters cannot be used.
|
|
X Table 4. When Multi-Byte Characters are not Allowed in Nonnumeric X Literals |
X OS/390 and VM |
X AIX, OS/2, and Windows |
X As a literal in the following: X ALPHABET clause X ASSIGN clause X CALL statement program-id X CANCEL statement X CLASS clause X CURRENCY SIGN clause X END METHOD header X END PROGRAM header X ENTRY statement X METHOD-ID paragraph X PADDING CHARACTER clause X PROGRAM-ID paragraph X RERUN clause X STOP statement |
X As a literal in the following: X ALPHABET clause X ASSIGN clause X CLASS clause X CURRENCY SIGN clause X END METHOD header X METHOD-ID paragraph X PADDING CHARACTER clause X RERUN clause X STOP statement X X X X X |
X BASIS statement (basis-name) |
X |
X COPY statement (text-name) |
X |
X COPY statement (library-name) |
X |
X >_Workstation_> Under AIX, OS/2, and Windows, you can include multi-byte
X as well as single-byte DBCS or EUC characters as alphanumeric literals
X (such as to initialize display fields). However, COBOL semantics applied
X to literals that contain both multi-byte and single-byte characters are
X not sensitive to the length (in bytes) of the individual characters.
X The rule of formation for mixed literals are as follows:
- X A nonnumeric literal (whether it contains any multi-byte characters or
X not) is delimited by either an opening and closing " or an opening and
X closing '. The " or ' must be represented as a single-byte character.
- X Nonnumeric literals containing a multi-byte character cannot be
X continued. The maximum length of a nonnumeric literal with multi-byte
X characters is limited only by the available positions in Area B on a
X single source line. <_Workstation_<
X >_Host_> Under OS/390 and VM, with the DBCS compiler option, the
X characters X'0E' and X'0F' in a nonnumeric literal will be recognized as
X shift codes for DBCS characters. That is, the characters between paired
X shift codes will be recognized as DBCS characters. Unlike a nonnumeric
X literal compiled under the NODBCS option, additional syntax rules apply to
X DBCS characters in a nonnumeric literal.
X These nonnumeric literals with double-byte characters have the following
X format:
X ___ Nonnumeric Literals with Double-Byte Characters ____________________
X | "EBCDIC-data<D1D2>EBCDIC-data" |
| |
|________________________________________________________________________|
-
X "
-
X The opening and closing delimiter (Alternatively, you can use
X apostrophes (') as delimiters.)
-
X <
-
X Represents the shift-out control character (X'0E')
-
X >
-
X Represents the shift-in control character (X'0F')
X Shift-out and shift-in control characters are part of the literal and must
X be paired with zero or an even number of intervening bytes.
X Nested shift codes are not allowed in the DBCS portion of the literal.
X The syntax rules for EBCDIC parts of the literal follow the rules for
X nonnumeric literals. The syntax rules for DBCS parts of the literal
X follow the rules for DBCS literals. The move and comparison rules for
X nonnumeric literals with double-byte characters are the same as those for
X any nonnumeric literal.
X The length of a nonnumeric literal with double-byte characters is its byte
X length, including the shift control characters. The maximum length is
X limited by the available space on one line in Area B. A nonnumeric
X literal with double-byte characters cannot be continued.
X A nonnumeric literal with double-byte characters is of the alphanumeric
X category.
X Under COBOL for OS/390 & VM, COBOL statements process nonnumeric literals
X with double-byte characters without sensitivity to the shift codes and
X character codes. The use of statements that operate on a byte-to-byte
X basis (for example, STRING and UNSTRING) can result in strings that are
X not valid mixtures of EBCDIC and double-byte characters. You must be
X certain that the statements use DBCS characters. See IBM COBOL for OS/390
X & VM Programming Guide for more information on using nonnumeric literals
X and data items with double-byte characters in statements that operate on a
X byte-by-byte basis. <_Host_<
X Hexadecimal notation can be used for nonnumeric literals. This
X hexadecimal notation has the following format:
X ___ Hexadecimal Notation Format for Nonnumeric Literals ________________
X | X"hexadecimal-digits" |
| |
|________________________________________________________________________|
-
X X"
-
X The opening delimiter for hexadecimal notation of a nonnumeric
X literal. (Alternatively, you can use apostrophes (') as delimiters.)
-
X "
-
X The closing delimiter for the hexadecimal notation of a nonnumeric
X literal. (Alternatively, you can use apostrophes (') as delimiters.)
X Hexadecimal digits can be characters in the range '0' to '9', 'a' to 'f',
X and 'A' to 'F', inclusive. Two hexadecimal digits represent a single
X character in the EBCDIC/ASCII character set. An even number of
X hexadecimal digits must be specified. The maximum length of a hexadecimal
X literal is 320 hexadecimal digits.
X The continuation rules are the same as those for any nonnumeric literal.
X The opening delimiter (X" or X') cannot be split across lines.
X The DBCS compiler option has no effect on the processing of hexadecimal
X notation of nonnumeric literals.
X The compiler will convert the hexadecimal literal into a normal nonnumeric
X literal. Hexadecimal notation for nonnumeric literals can be used
X anywhere nonnumeric literals can appear.
X The padding character for hexadecimal notation of nonnumeric literals is
X the blank (X'40' for OS/390 and VM) or (X'20' for AIX, OS/2, and Windows).
X Nonnumeric literals can be null-terminated, with the following format:
X ___ Format for Null-Terminated Nonnumeric Literals _____________________
X | Z"ddddd" |
| |
|________________________________________________________________________|
-
X Z"
-
X The opening delimiter for null-terminated notation of a nonnumeric
X literal. (Alternatively, you can use apostrophes (') as delimiters.)
-
X "
-
X The closing delimiter for a null-terminated notation of a nonnumeric
X literal. (Alternatively, you can use apostrophes (') as delimiters.)
X Null-terminated nonnumeric literals can be from 0 to 159 characters. You
X can specify any character except X'00', which is the null string
X automatically appended to the end of the literal. The length of the
X literal includes the terminating null character.
X Null-terminated literals can be used anywhere a nonnumeric literal can be
X specified and have the normal semantics of nonnumeric literals.
X Both characters of the opening delimiter for null-terminated literals (Z"
X or Z') must be on the same source line.
X The LENGTH intrinsic function, when applied to a null-terminated literal,
X returns the number of characters in the literal prior to but not including
X the terminating null. (The LENGTH special register does not support
X literal operands.)
X Null-terminated literals are not supported in "ALL literal" constructions.
© Copyright IBM Corp. 1991, 1998
IBM Library Server Copyright 1989, 2005 IBM Corporation. All rights reserved.
Return to library:
z/OS |
z/OS.e |
TPF |
z/VSE |
z/VM |
IBM Hardware |
IBM System z Redbooks
Glossary:
IBM terminology
Publications:
How to order publications
Readers:
Download IBM Library Reader |
Download IBM Softcopy Reader |
Download Adobe® Acrobat® Reader®
Library management:
Download IBM Softcopy Librarian
Contacts:
Contact z/OS
Adobe, the Adobe logo, Acrobat, the Acrobat logo, and Acrobat Reader are registered trademarks
of Adobe Systems incorporated.