z/OS TSO/E REXX User's Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Infinite Loops

z/OS TSO/E REXX User's Guide
SA32-0982-00

What happens when the control variable of a loop cannot attain the last number? For example, in the following exec segment, count does not increase beyond 1.
DO count = 1 to 10
  SAY 'Number' count
  count = count - 1
END

The result is called an infinite loop because count alternates between 1 and 0 and an endless number of lines saying Number 1 appear on the screen.

IMPORTANT - Stopping An Infinite Loop

When you suspect an exec is in an infinite loop, you can end the exec by pressing the attention interrupt key, sometimes labeled PA1. You will then see message IRX0920I. In response to this message, type HI for halt interpretation and press the Enter key. If that doesn't stop the loop, you can press the attention interrupt key again, type HE for halt execution, and press the Enter key.

HI will not halt an infinitely looping or long running external function, subroutine, or host command written in a language other than REXX and that was called by your exec. The HI condition is not checked by the REXX interpreter until control returns from the function, subroutine, or host command.

Example of EXEC1, an exec that calls an external function

/********************* REXX ****************************************/
/* Invoke a user-written external function, 'myfunct'.             */
/* not written in REXX.  For example, it might have been coded     */
/* in PL/I or assembler.                                           */
/*******************************************************************/
x = myfunct(1)
exit

If myfunct enters an infinite loop, pressing the attention interrupt key and entering HI will not stop myfunct. However, pressing the attention interrupt key and then entering HE will stop the function and the exec (EXEC1) that called it. HE does not automatically stop any exec that called EXEC1, unless you are running under ISPF. For more information about the HE condition, see z/OS TSO/E REXX Reference.

Note: HE does not alter the halt condition, which is raised by HI. If you entered HI before you entered HE (for example, you may have first issued HI and it failed to end your exec), the halt condition will remain set for the exec and all calling execs. HE will stop your exec, and then the halt condition, raised when you entered HI, will be recognized by any exec that called your exec.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014