Hello Guest it is April 27, 2024, 01:34:20 AM

Author Topic: Can you update the Global Registers?  (Read 518 times)

0 Members and 1 Guest are viewing this topic.

Can you update the Global Registers?
« on: November 09, 2023, 11:00:43 AM »
help please.

I am trying to update the Global Registers with the following code

Code: [Select]
-- -----------------------------------------------------------------
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
Happy Milling.

Offline gorf23

*
  •  189 189
    • View Profile
Re: Can you update the Global Registers?
« Reply #1 on: November 11, 2023, 01:32:28 PM »
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
Re: Can you update the Global Registers?
« Reply #2 on: November 11, 2023, 05:18:11 PM »
Thanks, I will give it a try and let you.
Happy Milling.