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

Procedures running in Parallel?

Status
Not open for further replies.

sci72

Technical User
May 29, 2004
28
0
0
US
At various sections of my main procedure I use a WHEN TARGET check to CALL a sub procedure to perform certain tasks based on responses I recieve. It seems that the main procedure continues to run in parallel to the sub procedure being called. I though that the main procedure would pause until the sub procedure was complete.

To test this I made something like this. I transmits 'NEW' in this case and I know the responce will be 'TYPE'. I did this to test the WHEN TARGET CALL.

proc main

transmit "new^m"
when target 0 "type" call subproc
mspause 100
usermsg "main procedure"

endproc

proc subproc

mspause 400
usermsg "sub procedure"

endproc


What I get is a "main procedure" message first, followed by a "sub procedure" message, and then a second "main procedure" message. Is the script actually running in two places at once in this case? What I want to happen is that the main procedure pauses or suspends until the sub procedure is complete.

Any help would be appreciated.
 
The when target command only fires when the string you are looking for is received. What is likely happening in your case is that the mspause 100 is not long enough to keep the script from displaying the main procedure message, then the subprocedure is called and its message displays. I'm not certain why you are receiving the "main procedure" message twice.

If you want the script to pause in a certain place, the best is to use a while 1/yield/endwhile loop, have it check in there for a variable that you set in your subprocedure to indicate it has been tripped, and then use an exitwhile to kick out of the endless loop.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top