Technical support and scripting issues
Moderators: JRL, Dorian (MJT support)
-
guyash2
- Junior Coder
- Posts: 40
- Joined: Thu May 05, 2005 2:45 pm
Post
by guyash2 » Sat Mar 17, 2012 6:31 pm
Hi,
I try to write a script which jump to the SRT
each time I press ENTER.
When trying this script:
Code: Select all
Onevent>Key_Down,VK13,0,message
label>loop
goto>loop
SRT>message
message>message
END>message
Everything works fine and each time I press ENTER I get the message.
But, when I try this script:
Code: Select all
Onevent>Key_Down,VK13,0,message
label>loop
goto>loop
label>guy
//do something
goto>loop
SRT>message
message>message
goto>guy
END>message
It works only on my
first press, and then it doesn't respond to my presses. (eventhough the log file shows that I'm always in the loop)
How can I fix it?
Thank you.
-
JRL
- Automation Wizard
- Posts: 3529
- Joined: Mon Jan 10, 2005 6:22 pm
- Location: Iowa
Post
by JRL » Sun Mar 18, 2012 7:30 am
You can't exit out of a subroutine and not let the subroutine complete. OnEvent won't fire again until the subroutine finishes so you only get one good key press. Try to use a variable flag, something like this
Code: Select all
Onevent>Key_Down,VK13,0,message
Let>messageflag=0
label>loop
If>messageflag=1
goto>guy
EndIf
goto>loop
label>guy
Let>messageflag=0
//do something
goto>loop
SRT>message
message>message
Let>messageflag=1
END>message