Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: peter81 on February 24, 2018, 01:10:04 PM
-
Hello,
can someone please help me with the code bellow. I have two led's on my screen named T01LED and T02LED and I want them to light up when tool number changes. I've put this code in PLC but it doesn't work. Thanks.
local inst = mc.mcGetInstance()
local currenttool = mc.mcToolGetCurrent(inst)
if (currenttool == "1") then
scr.SetProperty("T01LED", "Value", "1")
else
scr.SetProperty("T01LED", "Value", "0")
end
--------------------------
if (currenttool == "2") then
scr.SetProperty("T02LED", "Value", "1")
else
scr.SetProperty("T02LED", "Value", "0")
end
Regards,
Peter
-
You need to change 1 thing and it will work.
if (currenttool == 1) then Don't put the numbers in " ".
if (currenttool == 2) then
I put tested this code in the PLC script and it works just fine. =)
local inst = mc.mcGetInstance()
local currenttool = mc.mcToolGetCurrent(inst)
if (currenttool == 1) then
scr.SetProperty("TestLED", "Value", "1")
else
scr.SetProperty("TestLED", "Value", "0")
end
-
Thank you very much for that. I knew that was something simple. It work now thanks again.
Regards,
Peter