Skip to main content

Problem:

The z'string' is used in place of  'string' & x'00' to create a Null terminated character string.

Resolution:

A null-terminated string can be created by specifying Z'string' and can be used anywhere a nonnumeric literal is permitted.  The resultant literal is equivalent to concatenating X'00' (a null byte) to the end of the specified string. In other words, the two following lines are equivalent:

    Move z"my-literal" to an-item

    Move "my-literal" & X"00" to an-item

In the following example, the Picture declaration has an extra byte reserved for the zero (null) byte:

      01 my-name

Pic X(5) Value Z"Jane".

  The MOVE for this would be coded as:

     Move z"Jane" to my-name

Old KB# 6878