Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: Bill_O on July 30, 2020, 10:57:24 AM

Title: Custom m7
Post by: Bill_O on July 30, 2020, 10:57:24 AM
I have a custom m7 that i wrote.
When the gcode gets to M07 it does not even go into the macro.
Is there a setting I need to change to use the custom macro instead of the standard?

Code: [Select]
function M07()
--wx.wxMessageBox('In M07')
mc.mcCntlSetLastError(inst, "In M07")
local inst = mc.mcGetInstance()
--Get Mist On and Mister Auto handles
local hMist = mc.mcSignalGetHandle(inst, mc.OSIG_MISTON)
local hreg = mc.mcRegGetHandle(inst, 'iRegs0/MisterAuto')
--Get Mister Auto value
local MistVal = mc.mcRegGetValue(hreg)
if (MistVal == 0) then
mc.mcSignalSetState(hMist, 0)
--wx.wxMessageBox('Mist OFF')
else
mc.mcSignalSetState(hMist, 1)
--wx.wxMessageBox('Mist ON')
end
end
if (mc.mcInEditor() == 1) then
M07()
end
Title: Re: Custom m7
Post by: MN300 on July 30, 2020, 12:16:47 PM
M7 vs m7

https://www.machsupport.com/forum/index.php?topic=33809.msg235277;topicseen#msg235277
Title: Re: Custom m7
Post by: Bill_O on July 30, 2020, 01:39:34 PM
MN300
I have tried both but will look at that thread and try again.
Thanks,
Bill
Title: Re: Custom m7
Post by: KatzYaakov on August 03, 2020, 01:55:33 AM
mc.mcCntlSetLastError(inst, "In M07")
but you not define the inst,only line after
i suggest you if you use machhoby ,not use inst use"0" it will solve many of yours problem
Title: Re: Custom m7
Post by: Bill_O on August 03, 2020, 04:42:47 PM
Sorry all that i did not post this before.
It is functioning well.

Code: [Select]
function m7()
local inst = mc.mcGetInstance()
--Get Mist On and Mister Auto handles
local hMist = mc.mcSignalGetHandle(inst, mc.OSIG_MISTON)
local hreg = mc.mcRegGetHandle(inst, 'iRegs0/MisterAuto')
--Get Mister Auto value
local MistVal = mc.mcRegGetValue(hreg)
if (MistVal == 0) then
mc.mcSignalSetState(hMist, 0)
--wx.wxMessageBox('Mist OFF')
else
mc.mcSignalSetState(hMist, 1)
--wx.wxMessageBox('Mist ON')
end
end
if (mc.mcInEditor() == 1) then
m7()
end