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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Waitfor more than 1 string 3

Status
Not open for further replies.

aaiqbal

Programmer
Sep 15, 2003
26
US
The waitfor command is helpful because you can wait for an exact string. But if there is a possibility of more than 1 string based on the result of a test, how do I catch all of the strings. I tried "elseif waitfor" command but this ends up being useless because if the second waitfor string comes in while you're still waiting for the first string, it's never caught. Any help would be greatly appreciated. Thanks
 
One way to handle this is to determine what your final string the host system will send is, and to create an integer for the other strings. If they are received, they will be marked 1, otherwise they will remain 0.

In this example, the host system would ultimately return to "Make Selection" and possibly send a combination of "ERROR", and "COMPLETED" or "REJECTED" beforehand. Nested "if" statements are used to combine values and affect the next step.

Note that the Integers are global variables, above the Proc Main, so the values will be transmitted between sub routines:


Integer WASERROR, COMPLETED, REJECTED
Proc Main
When Target 1 "ERROR" call MARKERROR
When Target 2 "COMPLETED" call MARKCOMPLETE
When Target 3 "REJECTED" call MARKREJECT

Transmit "^M"
Waitfor "Make Selection" Forever
If COMPLETED == 1
If WASERROR == 1
Transmit "Exit^M"
Else
Transmit "Resend^M"
Endif
Else
If REJECTED == 1
Transmit "Exit^M"
Else
Transmit "Main^M"
Endif
Endif
EndProc


Proc MARKERROR
WASERROR = 1
EndProc


Proc MARKCOMPLETE
COMPLETED = 1
EndProc

Proc MARKREJECT
REJECTED = 1
EndProc


Robert Harris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top