Hello Guest it is June 15, 2025, 04:25:00 AM

Author Topic: Mach4 Registers and Buttons  (Read 2788 times)

0 Members and 1 Guest are viewing this topic.

Mach4 Registers and Buttons
« on: January 07, 2025, 09:04:40 AM »
I'm attempting to access/modify a register from a button using the up/down script functions. Register's do not appear to be accessible from a button however. Trying to print the version of Mach4 here does nothing, meaning it didn't find the register. I know I can access register's from DRO's but why not or HOW can I access them from a button?


local inst = mc.mcGetInstance();
local val = 1
local hreg, rc = mc.mcRegGetHandle(inst, "iregs/2010/IgnoreM6")

rc = mc.mcRegSetValueLong(hreg, val)
if (rc ~= mc.MERROR_NOERROR) then
   mc.mcCntlSetLastError(inst, "Error setting iregs/2010/IgnoreM6 ".. rc)
end



inst = mc.mcGetInstance();
hreg,rc = mc.mcRegGetHandle(inst, "core/global/Version")
if (rc == MERROR_NOERROR) then
   local rc = mcRegGetValue(hreg)
   mc.mcCntlSetLastError(mInst, "rc = " ..rc)
end

return val -- the script MUST return a value, otherwise, the control will not be updated.
Re: Mach4 Registers and Buttons
« Reply #1 on: January 08, 2025, 01:01:41 PM »
Make a function in the screen load script.  For example, the cycle start function or SpinCW functions.
Then in the siglib call that function from an input signal.  There is an example for the cycle start (if I remember correctly) for input 1 that is commented out.
Chad Byrd