EasyManuals Logo

IBM TSO/E REXX User Manual

IBM TSO/E REXX
242 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #72 background imageLoading...
Page #72 background image
DO UNTIL expression /* expression must be false */
instruction(s)
END
Use DO UNTIL loops when a condition is not true and you want to execute the loop
until the condition is true. The DO UNTIL loop tests the condition at the end of the
loop and repeats only when the condition is false. Otherwise the loop executes
once and ends. For example:
Example Using DO UNTIL
/******************************** REXX *****************************/
/* This exec uses a DO UNTIL loop to ask for a password. If the */
/* password is incorrect three times, the loop ends. */
/*******************************************************************/
password = 'abracadabra'
time = 0
DO UNTIL (answer = password) | (time = 3)
SAY 'What is the password?'
PULL answer
time = time + 1
END
Exercise - Using a DO UNTIL Loop
Change the exec in the previous exercise, Exercise - Using a DO WHILE Loop on
page 53, from a DO WHILE to a DO UNTIL loop and achieve the same results.
Remember that DO WHILE loops check for true expressions and DO UNTIL loops
check for false expressions, which means their logical operators are often reversed.
ANSWER
Possible Solution
/******************************** REXX *****************************/
/* This exec uses a DO UNTIL loop to keep track of window seats in */
/* an 8-seat commuter airline. */
/*******************************************************************/
window_seats = 0 /* Initialize window seats to 0 */
passenger = 0 /* Initialize passengers to 0 */
DO UNTIL (passenger >= 8) | (window_seats = 4)
/****************************************************************/
/* Continue until you have questioned all 8 passengers or until */
/* all the window seats are taken. */
/****************************************************************/
SAY 'Do you want a window seat? Please answer Y or N.'
PULL answer
passenger = passenger + 1
/* Increase the number of passengers by 1 */
IF answer = 'Y' THEN
window_seats = window_seats + 1
/* Increase the number of window seats by 1 */
ELSE NOP
END
SAY window_seats 'window seats were assigned.'
SAY passenger 'passengers were questioned.'
Using Looping Instructions
54
z/OS V1R1.0 TSO/E REXX Users Guide

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the IBM TSO/E REXX and is the answer not in the manual?

IBM TSO/E REXX Specifications

General IconGeneral
BrandIBM
ModelTSO/E REXX
CategoryComputer Hardware
LanguageEnglish

Related product manuals