Exercises - Using the TRACE Instruction

About this task

Write a program with a complex expression, such as:
IF (a > z) | (c < 2 * d) THEN ....

Define a, z, c, and d in the program and use the TRACE I instruction.

ANSWER
Figure 1. Possible Solution
/****************************** REXX ********************************/
/* This program uses the TRACE instruction to show how the language */
/* processor evaluates an expression, operation by operation.       */
/********************************************************************/
 a = 1
 z = 2
 c = 3
 d = 4

 TRACE I

 IF (a > z) | (c < 2 * d) THEN
   SAY 'At least one expression was true.'
 ELSE
   SAY 'Neither expression was true.'
When you run this program, it produces:
   12 *-* IF (a > z) | (c < 2 * d)
      >V>   "1"
      >V>   "2"
      >O>   "0"
      >V>   "3"
      >L>   "2"
      >V>   "4"
      >O>   "8"
      >O>   "1"
      >O>   "1"
      *-*  THEN
  13  *-*  SAY 'At least one expression was true.'
      >L>    "At least one expression was true."
At least one expression was true.

Task Task

Feedback


Timestamp icon Last updated: Tuesday, 7 January 2014


http://pic.dhe.ibm.com/infocenter/cicsts/v5r1/topic/com.ibm.cics.rexx.doc//dfhrx/dfhrx00040.html