555
« on: April 16, 2018, 10:15:54 AM »
Craig,
Here is a test I have set up on my computer at work.
I have a button to toggle Input10 on and off. I added a message to it. It runs in the PLC Script and only logs 1 message per button press.
local inst = mc.mcGetInstance()
local MessageVar = mc.mcCntlGetPoundVar(inst, 400)
local Input10 = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT10)
local hSig = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT10)
local State = mc.mcSignalGetState(hSig)
if State == 1 then
scr.SetProperty("TestTextBox", "Value", "On")
if MessageVar == 0 then
mc.mcCntlSetLastError(inst, "Input 10 is on.")
mc.mcCntlSetPoundVar(inst, 400, 1)
end
else
scr.SetProperty("TestTextBox", "Value", "Off")
mc.mcCntlSetPoundVar(inst, 400, 0)
end