The case can be tested also if n/y are acceptable:
LOOP PRINT "ENTER 'Y' OR 'N' ":;INPUT ANS,1
UNTIL INDEX('NY',UPCASE(ANS),1) REPEAT
*-- P.AM will contain a boolean value 0 for N, 1 for Y --*
FOR X = 1 TO (X+1)
PRINT "ENTER 'Y' OR 'N' ":;INPUT ANS,1
FIND UPCASE(ANS) IN "N":@AM:"Y" SETTING P.AM THEN P.AM -= 1 ; EXIT
NEXT X
----- Original Message ----
From: Keith Johnson [DATACOM] <[email protected]>
To: [email protected]
Sent: Monday, March 2, 2009 7:38:16 PM
Subject: Re: [U2] DO/WHILE vs IF THEN
Mark Johnson suggested the following change
><Before>
>GOOD.ANS=FALSE
>LOOP UNTIL GOOD.ANS DO
> PRINT "ENTER 'Y' OR 'N' ":;INPUT ANS
> IF ANS="Y" OR ANS="N" THEN GOOD.ANS=TRUE REPEAT
>
><after>
>LOOP WHILE TRUE DO
> PRINT "ENTER 'Y' OR 'N' ":;INPUT ANS
> IF ANS="Y" OR ANS="N" THEN EXIT
>REPEAT
These forms all work (Universe 10.2.0) and are progressively shorter
than the above
LOOP
PRINT "ENTER 'Y' OR 'N' ":;INPUT ANS
IF ANS="Y" OR ANS="N" THEN EXIT
REPEAT
LOOP
PRINT "ENTER 'Y' OR 'N' ":;INPUT ANS
UNTIL ANS="Y" OR ANS="N" DO
REPEAT
LOOP
PRINT "ENTER 'Y' OR 'N' ":;INPUT ANS
UNTIL ANS="Y" OR ANS="N" REPEAT
LOOP PRINT "ENTER 'Y' OR 'N' ":;INPUT ANS
UNTIL ANS="Y" OR ANS="N" REPEAT
Ray Wurlod was a great proponent of the LOOP WHILE READNEXT ID format.
I believe it may not compile on some MV systems.
Regards, Keith
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/