Sometimes, you may want to execute a group of instructions several times, or repeatedly until some event occurs. For example, you may wish to execute a group of instructions that gets lines of text from the user until he enters a blank line (ie, he presses the ENTER key without entering any other text).

To execute a group of instructions many times, you put them inside a loop. REXX has many ways to implement loops using the keywords DO and END. DO indicates the start of the loop, and is placed before the first instruction in the loop. END indicates the end of the loop, and is placed after the last instruction in the loop.

If you use the SIGNAL instruction within a loop, be sure to read the potential problem with SIGNAL inside a loop.