IBM Extension
IBM Extension

Null-terminated nonnumeric literals

Nonnumeric literals can be null-terminated, with the following format:

Read syntax diagramSkip visual syntax diagram
Format

>>-Z"--+------------------------+--"---------------------------><
       +-single-byte characters-+      
       +-DBCS characters--------+      
       '-mixed characters-------'      

Z"
The opening delimiter for null-terminated notation of a nonnumeric literal. (If the compiler option *APOST or the PROCESS statement option APOST is specified, the opening delimiter is Z'.) Both characters of the opening delimiter for null-terminated literals (Z" or Z') must be on the same source line.
"
The closing delimiter for a null-terminated notation of a nonnumeric literal. (If the compiler option *APOST or the PROCESS statement option APOST is specified, the closing delimiter is '.)

If a quotation mark is used in the opening delimiter, it must be used as the closing delimiter. Similarly, if an apostrophe is used in the opening delimiter, it must be used as the closing delimiter.

The content of the literal can include single-byte and/or double-byte characters, except that you cannot specify the single-byte character with the value X'00'. X'00' is the null character automatically appended to the end of the literal. The content of the literal is otherwise subject to the same rules and restrictions as a mixed literal.

The length of the string of single-byte and/or double-byte characters in the literal content can be 0 to 255 bytes. The actual length of the literal includes the terminating null character, giving a maximum length of 256 bytes.

A null-terminated nonnumeric literal has data class and category alphanumeric. It can be used anywhere a nonnumeric literal can be specified except that null-terminated literals are not supported in ALL literal figurative constants.

Avoid using a null-terminated literal to specify the external or internal object's name (such as program name, locale name, library name, procedure name, etc.) in a COBOL program; otherwise, compiler will replace the terminating null character by character "0", and a severity 20 error message will be issued to inform the user of this replacement.

The LENGTH intrinsic function, when applied to a null-terminated literal, returns the number of bytes in the literal prior to but not including the terminating null. (The LENGTH special register does not support literal operands.)

End of IBM Extension
End of IBM Extension