Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

REXX Loop conditional statement not working 1

Status
Not open for further replies.

Jongskie M.

Technical User
Dec 30, 2023
24
AE
Hi am neophyte here, can you check the script below on how to declare loops in the conditional statement which start from the highlighted below.

Code:
Call ZocCls
  login = ZocAsk(" What is your name:? ")
   
  IF login = "##CANCEL##" THEN DO

   [COLOR=#CC0000]answer = ZocRequest(" Command Cancelled , Retry?", "Yes", "No")[/color]

    DO UNTIL answer = "No" 
END
SAY

 CALL ZocMsgBox "Good Bye, Have a Nice Day!"

SIGNAL endit
 END

 IF login = " " THEN DO
 
    ZocMsgBox(" Null Input, Please Try Again ")
 
  END
 
 ELSE DO
    /* Request to Proceed */

    ZocMsgBox(" Your Request will execute now ")

CALL ZocDelay 1

   ZocSend "Welcome back Mr/Ms '"||login||"' Have a great Day!^M"
END
endit:  /* target for the SIGNAL command above */

EXIT
 
please post your code formatted between the marks:
[pre]
Code:
[/pre] [pre]...[/pre] [pre]
[/pre]

There is no error in your code, it works, the question is if it works as you expected.
 
Hi mikrom,

Yes the code is working so far, but the requirements doesn't met.

Scenario:
From the ZocRequest(Highlighted in Red) once the user pressed "Yes", the code exited instead it will loop again to

login = ZocAsk("What is your name:?"),

kindly add what am I missing. Thanks.
 
Hi Jongskie,

You didn't quite succeed in formatting the code, it looks a bit messy.
The DO UNTIL loop looks different too as you posted before, now when the answer is not "No", it seems to run forever.

If you want on the answer = "Yes" to return again to login, then create a label on the place where you read login name. Then when the answer = "Yes" jump to the label, when the answer = "No" jump to the end of the program as you done before.
 
I don't have the ZOC software, so this is what you can try in classical PC REXX (ooRexx, Regina):

Code:
logon:
CALL CHAROUT , "What is your name: "
PARSE UPPER PULL login

IF LOGIN = "##CANCEL##" THEN DO
  DO UNTIL answer = "YES" | answer = "NO"
    CALL CHAROUT , '"Command Cancelled, Retry? "Yes", "No": '
    PARSE UPPER PULL answer
  END
  IF answer = "YES" THEN DO
    SAY "Please Log On Again"
    SIGNAL logon
  END
  ELSE DO
    SAY "Good Bye, Have a Nice Day!"             
    SIGNAL endit
  END
END

IF LOGIN = " " THEN DO
  SAY "Null Input, Please Try Again"
END 
ELSE DO
  /* Request to Proceed */
  SAY "Your Request will execute now"
  CALL SYSSLEEP 1
  SAY "Welcome back Mr/Ms '"||login||"' Have a great Day!"
END

endit: /* target for the SIGNAL command above */
EXIT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top