Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: TTalma on March 09, 2019, 02:30:25 PM
-
I have a funtion, setToolDepth, in my macros folder. I was wondering how do I call this function from button?
I am using the blank button in the tool information area. I added the event for "left mouse up", and just put:
setToolDepth()
In it, but no surprise, it didn't work. How do I make this call. I would like to use the existing function so I don't have the same code in multiple places.
-
Hi,
the button is a part of the GUI. Its code will be compiled and included in the GUI chunk.
Your macros folder will be compiled and included in the Gcode interpreter chunk.
I memory serves me, you have a m code m1000 do you not? That code calls your setDepth() function?
Then attach this to your button:
local inst=mc.mcGetInstance()
mc.mcCntlGcodeExecuteWait(inst,'m1000')
You may have trouble if the machine is not in 'idle' state and the GUI chunk does not relinquish control.
Try it out.
Craig
-
Thanks That worked perfectly!
I'm still learning the nuances of the Mach 4 control structure. But it does make sense.
-
Hi,
I'm still learning the nuances of the Mach 4 control structure. But it does make sense.
When we say ' we are trying to learn Lua', its not really correct. The real challenge is learning how the different
parts of Mach interact and the vagaries of Machs API not Lua at all.
Craig