Page 1 of 1

What is the correct order of evaluation of condition phrases.

Posted: Sat Oct 17, 2015 9:02 pm
by RaGa
Hi

I read this in the TSO/E Rexx manual:
3.4.3 Conditional phrases (WHILE and UNTIL)
.
.
For a WHILE loop, the condition is evaluated at the top of the group of instructions. For an UNTIL loop, the condition is evaluated at the bottom--before the control variable has been stepped.
I am not very clear on the WHILE. It describes the an UNTIL phrase well but not for the WHILE phrase. The WHILE condition is evaluated before or after the control variable has been stepped? Can you please guide me?

Re: What is the correct order of evaluation of condition phrases.

Posted: Sat Oct 17, 2015 9:28 pm
by enrico-sorichetti
while the while logic is clear

the until logic is a bit weirder
the loop is executed at least once

see

Code: Select all

i = 4
do  until  i > 3
    say "inside" i
    i = i + 1
end
say "at end" i

i = 1
do  until  i > 3
    say "inside" i
    i = i + 1
end
say "at end" i

Re: What is the correct order of evaluation of condition phrases.

Posted: Sun Oct 18, 2015 3:53 pm
by RaGa
I thought it other way. Thanks for the example. I'll need to experimnet more to uderstand it.