601
Mach4 General Discussion / Re: Using a button script to set jog increments etc
« on: May 20, 2018, 12:52:27 PM »
The screen script is a screen resource. Meaning it is part of the screen set. You edit the screen to edit the script. It has nothing to do with a machine profile other than the profile determine WHAT screen is use with it. Fore example, multiple profile could use the same screen set. Or each profile could use a different set.
As Craig mentioned, the larger ScreenScript.lua is generated from smaller script snippets in the screen. So you can't edit the ScreenScript.lua file directly. See section 5 of "Mach4 Screen Editor V1.0.pdf" in the docs folder.
Usually, if one wants to make a function available for the screen elements, the function is put in the screen load script. This allows for any button to call that function from their respective event scripts, etc.. So you will see the CycleStart() function in the screen load script.
Now, do you NEED to put the code into the screen load script? It depends. If the code is something that is repetitive and common, then adding it as a function in the screen load script becomes desirable. But if the button code is very specific to a certain button, then just use the button event script to do the whole job. A LOT of times, doing all of the the code in the button event script is more clear to the intent. Readability is important a year from now if you decide to change something and have pretty much forgotten what you are doing now. It really depends on what is most comfortable/effective for you.
Steve
As Craig mentioned, the larger ScreenScript.lua is generated from smaller script snippets in the screen. So you can't edit the ScreenScript.lua file directly. See section 5 of "Mach4 Screen Editor V1.0.pdf" in the docs folder.
Usually, if one wants to make a function available for the screen elements, the function is put in the screen load script. This allows for any button to call that function from their respective event scripts, etc.. So you will see the CycleStart() function in the screen load script.
Now, do you NEED to put the code into the screen load script? It depends. If the code is something that is repetitive and common, then adding it as a function in the screen load script becomes desirable. But if the button code is very specific to a certain button, then just use the button event script to do the whole job. A LOT of times, doing all of the the code in the button event script is more clear to the intent. Readability is important a year from now if you decide to change something and have pretty much forgotten what you are doing now. It really depends on what is most comfortable/effective for you.
Steve