Machsupport Forum

Mach Discussion => Mach4 General Discussion => Mach4 Toolbox => Topic started by: wildu on August 05, 2017, 07:42:56 PM

Title: Read external input
Post by: wildu on August 05, 2017, 07:42:56 PM


Hello everyone, I'm new working with Mach 4 and I have the following problem:

I made a M Code (M110) to read an external input and depending on its state show a text. The problem is that running the M110 from the MDI does not read the input and I do not know if I have to activate something or I have to do it another way.

Thanks for the help...

Test code:

function m110()

   local inst = mc.mcGetInstance()
   hReg = mc.mcIoGetHandle(inst, mc.ISIG_INPUT1)
   
   if hReg == 1 then
        wx.wxMessageBox("External input activated!")
    else
        wx.wxMessageBox("External input disabled!")
    end
end

if (mc.mcInEditor() == 1) then
 m110()
end