INTERPRET
Purpose
INTERPRET expression ;
INTERPRET processes instructions that have been built dynamically by evaluating expression.
The expression is evaluated and is then processed (interpreted) just as though the resulting string were a
line inserted into the program (and bracketed by a DO; and an END;).
Any instructions (including INTERPRET instructions) are allowed, but note that constructions such as
DO...END and SELECT...END must be complete. For example, a string of instructions being interpreted
cannot contain a LEAVE or ITERATE instruction (valid only within a repetitive DO loop) unless it also
contains the whole repetitive DO...END construct.
A semicolon is implied at the end of the expression during execution, if one was not supplied.
Example:
data='FRED'
interpret data '= 4'
/* Builds the string "FRED = 4" and */
/* Processes: FRED = 4; */
/* Thus the variable FRED is set to "4" */
Example:
data='do 3; say "Hello there!"; end'
interpret data /* Displays: */
/* Hello there! */
/* Hello there! */
/* Hello there! */
Notes:
1. Label clauses are not permitted in an interpreted character string.
2. If you are new to the concept of the INTERPRET instruction and are getting results that you do not
understand, you may find that executing it with TRACE R or TRACE I in effect is helpful.
Example:
/* Here is a small REXX program. */
Trace Int
name='Kitty'
indirect='name'
interpret 'say "Hello"' indirect'"!"'
When this is run, it gives the trace:
kitty
3 *-* name='Kitty'
>L> "Kitty"
4 *-* indirect='name'
>L> "name"
5 *-* interpret 'say "Hello"' indirect'"!"'
>L> "say "Hello""
>V> "name"
>O> "say "Hello" name"
>L> ""!""
>O> "say "Hello" name"!""
*-* say "Hello" name"!"
>L> "Hello"
>V> "Kitty"
INTERPRET
Chapter 13. Keyword Instructions 145