Using Looping Instructions
There are two types of looping instructions,
repetitive loops
and
conditional loops
. Repetitive loops let
you repeat instructions a certain number of times. 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. It uses a constant after the keyword DO.
DO 5
SAY 'Hello!'
END
When you run this example, it produces five lines of
Hello!
:
Hello!
Hello!
Hello!
Hello!
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
SAY 'Hello!'
END
A variable that controls the number of times a loop repeats is called a
control variable
. Unless you
specify otherwise, the control variable increases by 1 each time the loop repeats.
/******************************** REXX *******************************/
/* This program uses the input of a whole number from 1 to 12 that
*/
/* represents a month.
It produces the number of days in that
*/
/* month.
*/
/*********************************************************************/
ARG 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'.'
Figure 19. Possible Solution
Control Flow within a Program
Chapter 4. Controlling the Flow within a program
39
Содержание SC34-5764-01
Страница 1: ...CICS Transaction Server for VSE ESA REXX Guide SC34 5764 01...
Страница 2: ......
Страница 3: ...CICS Transaction Server for VSE ESA REXX Guide SC34 5764 01...
Страница 22: ...xx CICS TS for VSE ESA REXX Guide...
Страница 23: ...Part 1 User s Guide Copyright IBM Corp 1992 2009 1...
Страница 24: ...2 CICS TS for VSE ESA REXX Guide...
Страница 40: ...18 CICS TS for VSE ESA REXX Guide...
Страница 54: ...Using Variables and Expressions 32 CICS TS for VSE ESA REXX Guide...
Страница 106: ...84 CICS TS for VSE ESA REXX Guide...
Страница 110: ...88 CICS TS for VSE ESA REXX Guide...
Страница 122: ...100 CICS TS for VSE ESA REXX Guide...
Страница 123: ...Part 2 Reference Copyright IBM Corp 1992 2009 101...
Страница 124: ...102 CICS TS for VSE ESA REXX Guide...
Страница 130: ...Introduction 108 CICS TS for VSE ESA REXX Guide...
Страница 152: ...REXX General Concepts 130 CICS TS for VSE ESA REXX Guide...
Страница 224: ...Functions 202 CICS TS for VSE ESA REXX Guide...
Страница 252: ...230 CICS TS for VSE ESA REXX Guide...
Страница 278: ...256 CICS TS for VSE ESA REXX Guide...
Страница 312: ...DB2 Interface 290 CICS TS for VSE ESA REXX Guide...
Страница 316: ...High level Client Server Support 294 CICS TS for VSE ESA REXX Guide...
Страница 340: ...318 CICS TS for VSE ESA REXX Guide...
Страница 344: ...for execs Commands 322 CICS TS for VSE ESA REXX Guide...
Страница 399: ...Part 3 Appendixes Copyright IBM Corp 1992 2009 377...
Страница 400: ...378 CICS TS for VSE ESA REXX Guide...
Страница 438: ...416 CICS TS for VSE ESA REXX Guide...
Страница 442: ...System Definition Customization Administration 420 CICS TS for VSE ESA REXX Guide...
Страница 446: ...Security 424 CICS TS for VSE ESA REXX Guide...
Страница 448: ...426 CICS TS for VSE ESA REXX Guide...
Страница 464: ...442 CICS TS for VSE ESA REXX Guide...
Страница 466: ...444 CICS TS for VSE ESA REXX Guide...
Страница 468: ...446 CICS TS for VSE ESA REXX Guide...
Страница 476: ...454 CICS TS for VSE ESA REXX Guide...
Страница 478: ...456 CICS TS for VSE ESA REXX Guide...
Страница 479: ......
Страница 480: ...SC34 5764 01...
Страница 481: ...Spine information CICS TS for VSE ESA REXX Guide...