Hi,
sorry misclicked and posted before I was ready....(my missus says that all the time?

)
When you wish to run the code in the editor the function must be called......but what program or device is there to do the calling?
There isn't a parent program to do it and that's where that little bit of extra code at the end of just about every macro in Mach4
comes in.
It says that.....IF Mach is in Editor Mode......THEN call the function m101() (please...)
So that little bit of code formally calls you macro function code so you can run/debug it. The extra code has no revelance to
your Gcode program as Mach is not in Editor mode at that time so the call is ignored.
Ok....we now have a structure for your first macro, but what is your macro to do?
You want a text box that has to be cleared by the operator. That's easy. Mach4, or rather Lua which underpins it, makes
very liberal use of wxWidgets, which does amongst other things (a very VERY
VERY GREAT number of other things)
a textbox called wx.MessageBox.
wxWidgets is one of those steep learning curves that you will encounter....its written and composed by computer geeks for computer
geeks, and from what my mother told me its a wonder that they are not all blind!
Fortunately wxMessage box is easy enough that it doesn't risk your eyesight.
function m102()
local inst=mc.mcGetInstance()
wx.wxMessageBox('OK, clear the bloody box you plonker!')
end
if (mc.mcInEditor()==1) then
m102()
end
Note that I called and save the macro as m102() as I already had an m101() which I did not wish to overwrite.
You might ask what is the:
local inst=mc.mcGetInstance()
line all about?
Firstly Lua is a self memory managed language. When a variable is created it will stay in memory until its 'garbage collected'
by Lua. When you specify 'local' it means that its safe for Lua to garbage collect the variable when it goes out of scope. If you
don't declare your variable as local then it will be global and clog up your PC. The rule in Lua is that all variables should be
local UNLESS there is some specific and overriding need to do otherwise.
Secondly, Mach is intended, not as yet implemented, but will be one day, to run in multiple instances on one PC, referring to different
machines or perhaps different sections of one large production machine. As such when addressing Mach you need to specify
which 'instance' you are referring to. While its not required here...I put it there so you get used to seeing it, you will need it in
times to come.
Craig