I cant disable a CUSTOM OnEvent handler.

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
AnomalyNick
Newbie
Posts: 3
Joined: Thu Nov 28, 2013 2:03 am
Location: Australia
Contact:

I cant disable a CUSTOM OnEvent handler.

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,,

User avatar
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
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

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

Dick99999
Pro Scripter
Posts: 84
Joined: Thu Nov 27, 2008 10:25 am
Location: Netherlands

Post by Dick99999 » Mon Dec 02, 2013 7:49 am

Isn't that the same issue as in the on click event thread? When I took the disable event handler out of the event handler itself, it worked. see: http://www.mjtnet.com/usergroup/disable ... t8064.html ?

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts