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

How to do 'waitfor' with multiple text phrase ?

Status
Not open for further replies.

tpq

Programmer
Apr 2, 2003
12
US
I have a situation that I have to wait for either:

(1) "Press any key for more"
(2) "Command:?"

The problem is I don't know which on the above will arrive.
If I am using the 'when' command with 'target' then I can't
return the original caller. For example:

proc main

integer nRet

nRet = processText()
if nReturn == 1
termmsg "There are more"
elseif nReturn == 2
termmsg "Enter command now"
else
termmsg "Error - Invalid text received"
endif
endproc


func processText:integer


waitfor "Press any key for more"
if success
return 1
else
waitfor "Command:?"
if success
return 2
endif
endif
return 0
endfunc

If I use 'when' command inside the 'processText" function
then how do return to the 'main' ?

Thanks
 
You should be OK with the two when target commands and associated procedures as the script will resume execution where it was originally when the when target commands fired (and the called procedure has ended).

I also have a sample script another ASPECT user sent me at that shows how to wait for up to three text strings at the same time. However, it uses when target behind the scenes, so it may not be any better than your current situation.


aspect@aspectscripting.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top