Using Looping Instructions
There are two types of looping instructions, repetitive loops and conditional
loops. Repetitive loops allow you to repeat instructions a certain number of times,
and conditional loops use a condition to control repeating. All loops, regardless of
the type, begin with the DO keyword and end with the END keyword.
Repetitive Loops
The simplest loop tells the language processor to repeat a group of instructions a
specific number of times using a constant following the keyword DO.
DO 5
END
When you run this example, you see five lines of Hello!.
You can also use a variable in place of a constant as in the following example,
which gives you the same results.
number = 5
DO number
END
Possible Solution
/******************************** REXX *****************************/
/* This exec requests the user to enter a month as a whole number */
/* from 1 to 12 and responds with the number of days in that
/* month.
/*******************************************************************/
SAY 'To find out the number of days in a month,'
SAY 'Enter the month as a number from 1 to 12.'
PULL month
SELECT
WHEN month = 9 THEN
days = 30
WHEN month = 4 THEN
days = 30
WHEN month = 6 THEN
days = 30
WHEN month = 11 THEN
days = 30
WHEN month = 2 THEN
days = '28 or 29'
OTHERWISE
days = 31
END
SAY 'There are' days 'days in Month' month '.'
SAY 'Hello!'
Hello!
Hello!
Hello!
Hello!
Hello!
SAY 'Hello!'
Using Conditional Instructions
Chapter 4. Controlling the Flow Within an Exec
*/
*/
47