OnEvent triggers SubRoutine but then start the script from the beginning.

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
Grovkillen
Automation Wizard
Posts: 1009
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

OnEvent triggers SubRoutine but then start the script from the beginning.

Post by Grovkillen » Mon Sep 20, 2021 6:31 am

Code: Select all

Let>counter=0

Message>counter

//DOWN
OnEvent>KEY_DOWN,VK40,0,TEST_ROUTINE,{1}
//ESC
OnEvent>KEY_DOWN,VK27,0,EXIT_APP

Label>mainLoopStart
Wait>0.05
Goto>mainLoopStart


SRT>TEST_ROUTINE
**BREAKPOINT**
  Add>counter,TEST_ROUTINE_Var_1
  
  //why is the script starting from top after I have used the arrow DOWN to start the TEST_ROUTINE
END>TEST_ROUTINE

SRT>EXIT_APP
  Exit>
END>EXIT_APP
Last edited by Grovkillen on Mon Sep 20, 2021 7:20 am, edited 1 time in total.
Let>ME=%Script%

Running: 15.0.24
version history

User avatar
Grovkillen
Automation Wizard
Posts: 1009
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: OnEvent triggers SubRoutine but then start the script form the beginning.

Post by Grovkillen » Mon Sep 20, 2021 6:42 am

I have found the problem.... the passed variable will mess the loop up:

Code: Select all

Let>counter=0

Message>counter

//DOWN
OnEvent>KEY_DOWN,VK40,0,TEST_ROUTINE,{1}
//UP
OnEvent>KEY_DOWN,VK38,0,TEST_ROUTINE
//ESC
OnEvent>KEY_DOWN,VK27,0,EXIT_APP


Label>mainLoopStart
Wait>0.05
Goto>mainLoopStart


SRT>TEST_ROUTINE
**BREAKPOINT**
  Let>TEST_Var_1=0*TEST_ROUTINE_Var_1
  If>TEST_Var_1=0
    Add>counter,TEST_ROUTINE_Var_1
  Else>
    Let>counter=100
  Endif>
END>TEST_ROUTINE

SRT>EXIT_APP
  Exit>
END>EXIT_APP
Let>ME=%Script%

Running: 15.0.24
version history

User avatar
Grovkillen
Automation Wizard
Posts: 1009
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: OnEvent triggers SubRoutine but then start the script from the beginning.

Post by Grovkillen » Fri Sep 24, 2021 6:45 am

[EDIT] posted in wrong thread.
Let>ME=%Script%

Running: 15.0.24
version history

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