次の例は、ヌル終了ストリングの処理方法をいくつか示しています。
01 L pic X(20) value z'ab'. 01 M pic X(20) value z'cd'. 01 N pic X(20) value z'xyz'. 01 N-Length pic 99 value zero. 01 N pic X(20) value z'xyz'. 01 X pic X(20). 01 Y pic X(13) value 'Hello, World!'. . . . * Display null-terminated string Inspect N tallying N-length for characters before initial x'00' Display 'N: ' N(1:N-Length) ' Length: ' N-Length . . . * Move null-terminated string to alphanumeric, strip null Unstring N delimited by X'00' into X . . . * Create null-terminated string String Y delimited by size X'00' delimited by size into N. . . . * Concatenate two null-terminated strings to produce another String L delimited by x'00' M delimited by x'00' X'00' delimited by size into N.
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.