Hi,
Mach4/Lua/Gcode beginner here. I'm trying to write a macro for Mach4Hobby, that I've had a look at the exemplary m162.mcs in Profiles/Mach4Mill/Macros/ folder and I came across this in line 10
function m162(hParam) --The param is a P value called from Gcode. M162P3 for example.
which leads me to believe that I can specify parameters that are passed to my macros with a "P", following my M-code. Now I've written the following for M100 into m100.mcs:
local inst = mc.mcGetInstance()
function m100(hParam)
if (hParam ~= nil) then
mc.mcCntlLog(inst, string.format("hParam %d", hParam), "",0)
end
end
if (mc.mcInEditor() == 1) then
m100(1)
end
From what I inferred from m162.mcs, if I add a line "M100P10" to my MDI, the called macro should get a numeric 10 as an argument and this should show up in the log. However, when I run it, the output is always "hParam 466550640", no matter what value I add as a "P value", even if I don't pass a parameter at all (i.e., just putting "M100").
There is apparently an argument passed to the macro, but it seems like is contains the wrong value, or some handle/reference or whatever. Why is that? Is this not how it's supposed to be used? If not, what is a P value and how can I get a parameter into my macro from G-code/MDI? Unfortunately, I cannot find any documentation on that, but maybe I just missed it?
(Using Mach4Hobby 4.2.0.5036)