Steve, I've been wanting to add the Preload function to our mill for weeks now, today I finally jumped in and did it, it took all of 5 minutes with your "T" macro you posted on this topic. It works great.
I'm talking to the Click PLC via Modbus Register. Here is the code I'm using, hopefully someone else can get some use out of it. =)
--Hurco Pocket Preload
function t(tool)
local inst = mc.mcGetInstance()
local Requested = mc.mcToolGetSelected(inst)
local Current = mc.mcToolGetCurrent(inst)
local tonumber ToolNum = Requested
local Pocket = mc.mcToolGetData (inst, mc.MTOOL_MILL_POCKET, ToolNum)
local DS2 = mc.mcRegGetHandle(inst,"Click/Requested Car Pos")
mc.mcRegSetValue(DS2,Pocket)
mc.mcCntlSetLastError(inst, "Preload Complete.")
end --t
if (mc.mcInEditor() == 1) then
t()
end
Thanks again Steve!