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

Using "When Target" 3

Status
Not open for further replies.

BrianMiles

Technical User
Apr 17, 2007
4
US
I am trying to make a script that will listen on the com port for certain messages and then call a process. I tried this:

While 1
when target 0 " String 1 " call myproc
when target 0 " String 2 " call myproc
when target 0 " String 2 " call myproc
endwhile

myproc
...
endproc


It didn't pick up on these messages all the time just once in a while.

Am I doing this the right way to look for certain messages from what is received on the com port?

Is there a better way? Maybe the Switch command?
 
I am not 100%, but try placing those "when target" statements outside of your while loop...
 
Yes, you defintely want those outside of any while loop so they are only executed once. I helped someone in the past who was seeing some "weird" behavior when they were continually executing the same when target commands over and over.

 
So if I execute them once will they continuasly be active unless I clear them?
 
Brian... I don't believe you should re-use Target '0' if you are looking for 3 Different strings.

Try...
Code:
when target 0 " String 1 " call myproc
when target 1 " String 2 " call myproc
when target 2 " String 3 " call myproc
 
Thanks 1337hax0rz, knob, and comtechau for your quick responses. I was able to get the script up and running minutes after you replied.:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top