Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: Rimmel on August 03, 2022, 08:18:53 AM

Title: Mach4 screen action/script precedence
Post by: Rimmel on August 03, 2022, 08:18:53 AM
On a button there are actions and scripts that can be attached to the button (see picture).

It seems both can be used together e.g. I have an action assigned and also a script and they both execute, but what is the order they execute?

Action then script?

thanks
Title: Re: Mach4 screen action/script precedence
Post by: joeaverage on August 03, 2022, 05:22:06 PM
Hi,

Quote
Action then script?

No idea. An action is internally programmed in Machs core whereas the script is part of the runtime ScreenScript. They do not run simultaneously
but rather consecutively as co-routines. The toggle button is a screen element and therefore the screen script must be running for the button event to be detected
and I would guess therefore that the script would run, given that the ScreenScript is the active chunk and THEN be released to Machs core whereon the Action would run.

This is just a guess.

Craig
Title: Re: Mach4 screen action/script precedence
Post by: Cbyrdtopper on August 04, 2022, 09:57:01 AM
You could set up a test that pops up a message. 
Set the action to something that runs as a function from the screen load script... ie the cycle stop function and add a mc.mcCntlSetLastError(inst, "Test Action") to the function and then have your script do the same thing:
local inst = mc.mcGetInstance()
mc.mcCntlSetLastError(inst, "Test Script")

I tried this on my end.  I couldn't get a button to do any actions.  Weird.  I never use the actions, I always add scripts to buttons. 
Maybe try this on your end and see what you can do.