Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: JimAndi on November 09, 2023, 11:00:43 AM
-
help please.
I am trying to update the Global Registers with the following code
-- -----------------------------------------------------------------
function SetMillPark()
local inst = mc.mcGetInstance()
scr.SetProperty("droMillParkX", "Value", tostring(mc.mcAxisGetMachinePos(inst, mc.X_AXIS)))
scr.SetProperty("droMillParkY", "Value", tostring(mc.mcAxisGetMachinePos(inst, mc.Y_AXIS)))
local MillParkXReg = mc.mcRegGetHandle(inst, 'gRegs0/MillParkX')
mcRegSetUserData(MillParkXReg, tostring(mc.mcAxisGetMachinePos(inst, mc.X_AXIS)))
local MillParkYReg = mc.mcRegGetHandle(inst, 'gRegs0/MillParkY')
mcRegSetUserData(MillParkYReg, tostring(mc.mcAxisGetMachinePos(inst, mc.Y_AXIS)))
end -- function end
-- -----------------------------------------------------------------
SetMillPark()
and it is not updating the Global Register for mill park X and Y values.
Thanks
Jim
-
i think you need to use val = mcRegGetValueString(number hReg), mcRegSetValueString(number hReg,'string value), or val = mcRegGetValue(number hReg), rc = mc.mcRegSetValue(number hReg, number value)
these work for me mcRegSetUserData i don't think will work correct..
correct me if I am am wrong.
Gary
-
Thanks, I will give it a try and let you.