Technical support and scripting issues
Moderators: Dorian (MJT support), JRL
-
AnomalyNick
- Newbie
- Posts: 3
- Joined: Thu Nov 28, 2013 2:03 am
- Location: Australia
-
Contact:
Post
by AnomalyNick » Thu Nov 28, 2013 11:34 am
I cant disable a CUSTOM OnEvent handler. I use the disable command with and without the Extra parm and it makes no difference. I step through the code and it just keeps looping through WAIT-FOR-MACACTION after it has completed the MACACTION-FAILED routine.
Thanks,
Nick
Code: Select all
at start ...
// Setup OnEvent processes
///////////////////////////////////////////////////////////////////
OnEvent>FILE_EXISTS,%BotFolder%\MacAction.txt,0,PROCESS-ACTION
OnEvent>WINDOW_OPEN,Microsoft Visual Basic,2,CLOSE-VB-ERROR-WINDOW
OnEvent>CUSTOM,WAIT-FOR-MACACTION,Flag_MacAction_Failed,MACACTION-FAILED
///////////////////////////////////////////////////////////////////
then later on ...
SRT>MACACTION-FAILED
//********************
Let>Flag_MacAction_Failed=FALSE
// Temporarily Disable On Event proceeses
OnEvent>FILE_EXISTS,%BotFolder%\MacAction.txt,0,
OnEvent>WINDOW_OPEN,Microsoft Visual Basic,2,
OnEvent>CUSTOM,WAIT-FOR-MACACTION,,
-
Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
-
Contact:
Post
by Marcus Tettmar » Thu Nov 28, 2013 3:05 pm
What does the trigger routine do? Maybe the condition which fires it is still valid. E.g. if you are triggering based on an open window and that window is still open then it will keep firing.
What I would do is set a flag to say we're done and only do if the flag has not been set. Use a global variable to signify we're done. Something like:
Code: Select all
Let>OK_TO_DO=TRUE
OnEvent>CUSTOM,WAIT-FOR-MACACTION,Flag_MacAction_Failed,MACACTION-FAILED
.. bla bla
SRT>MACACTION-FAILED
If>OK_TO_DO=TRUE
....
.... your code here
....
//finally set our flag to stop this happening again - can always be UNSET by our trigger routine ...
Let>OK_TO_DO=FALSE
Endif
END>MACACTION-FAILED
-
AnomalyNick
- Newbie
- Posts: 3
- Joined: Thu Nov 28, 2013 2:03 am
- Location: Australia
-
Contact:
Post
by AnomalyNick » Sun Dec 01, 2013 12:52 pm
I have written a simple routine to test OnEvent but it behaves very inconsistently. When I step through it, it works correctly when n =3 but after that it doesn't shut down immediately as it should. And when I run it in a normal manner it does'nt produce any messages (in test.txt file) at all.
Code: Select all
// Test OnEvent
Let>n=0
OnEvent>CUSTOM,MyTriggerSub,DoIT,DoSomething
SRT>MyTriggerSub
Let>n=%n%+1
If>%n%=3
Let>DoIT=TRUE
Endif
END>MyTriggerSub
SRT>DoSomething
GetTime>time
WriteLn>c:\temp\test.txt,result,%time% value of n is %n%
Let>DoIT=FALSE
OnEvent>CUSTOM,MyTriggerSub,DoIT,
END>DoSomething