Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: cd_edwards 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.
-
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.