John (Walker);

I believe you are confusing the notion of a null terminated string and
a "line" whose length is zero.  A "null" character (in both ASCII and
EBCDIC) is a byte whose value is 0x00, i.e., all bits are zero.

In the "C" programming language (and many other programming
languages), the end of a character string is defined as the first
occurrence of a null byte when viewing the string from "left to
right".  For example, the character string "ABC" consists of the
single characters A, B and C, followed by a 0x00 byte.  The logical
length of this string is three.

A "C" string consisting solely of a 0x00 byte is a null string and the
logical length of this string is zero.

Rexx, unlike C, does not have the notion of null terminated strings.
In fact, a string in Rexx may contain any combination of character
values.  A null string in Rexx is one whose length is zero.

The following simple Rexx program (and its corresponding output)
illustrates these Rexx string concepts.

---------------------------- The Program -----------------------------

/* REXX */

Parse version RexxVers

say RexxVers
say

String_1 = "ABC"
say "String_1:"
say "   Length:" Length(String_1)
say "   Value:  0x"C2X(String_1)
say

String_2 = X2C("00")
say "String_2:"
say "   Length:" Length(String_2)
say "   Value:  0x"C2X(String_2)
say

String_3 = ""
say "String_3:"
say "   Length:" Length(String_3)
say

Return (0)

----------------------------- The Output -----------------------------

REXX-ooRexx_4.1.3(MT) 6.03 4 Jul 2013

String_1:
   Length: 3
   Value:  0x414243

String_2:
   Length: 1
   Value:  0x00

String_3:
   Length: 0

----------------------------------------------------------------------

You'll notice that I executed this Rexx program on a platform other
than z/OS (the actual system is the 64-bit version of Microsoft
Windows 7 Ultimate).  I did this deliberately in an attempt to
illustrate that even on a platform which is biased towards null
terminated strings, Rexx strings are not null terminated.  You can
run this yourself on z/OS.

Unfortunately, IBM's EXECIO documentation is written rather poorly.
In particular, this statement taken from the TSO/E REXX Reference is
misleading and imprecise:

   "When EXECIO writes an arbitrary number of lines from a list of
    compound variables, it stops when it reaches a null value or an
    uninitialized variable (one that displays its own name)."

A "null value" in this context really means a variable whose value
LENGTH is zero, not whose actual value is a single null byte.

The second part of that same sentence (talking about an "uninitialized
variable") is also imprecise and somewhat incorrect.  Rexx absolutely
distinguishes the "initialized" versus "uninitialized" states of a
variable.  While it is true that the implicit value of an uninitialized
variable is the name of that variable, the explicitly assigned value of
a variable may certainly be its own name.  For example:  X = "X"

Bob

Reply via email to