Previous Topic: Received Message Address Space Is Not ActiveNext Topic: Problems with WTO and WTOR Messages in Subsystem Interface


Uninitialized Variables Yield Unpredictable Results

Symptom:

My statements (usually host commands) that rely on uninitialized variable values are yielding unpredictable results.

Solution:

REXX sets any uninitialized variable to the character string that comprises the name of that variable, so you do not have to enclose literal strings in quotation marks. For example, if a variable named TSO is not initialized, REXX evaluates both TSO and "TSO" identically.

Relying on this feature to avoid using quotes can be dangerous, because if the variable is ever initialized somewhere, suddenly statements (usually host commands) that have been relying on its uninitialized value yield unpredictable results.

For instance, consider the following SAY statements:

say "TSO"
SAY TSO

If you want the value of the variable TSO to always be TSO, it is safer to use the SAY statement with quotation marks (say "TSO"). This coding ensures that TSO, even if initialized as a variable somewhere for another purpose, will not be evaluated, and that the literal string value will always be returned.