Hello Guest it is May 14, 2021, 04:19:51 AM

Author Topic: PLC Script and global variables  (Read 820 times)

0 Members and 1 Guest are viewing this topic.

PLC Script and global variables
« on: June 28, 2017, 05:51:20 PM »
Here's what I'm trying to do...

CurrentPosX = mc.mcCntlGetDistToGo(inst, 0)
CurrentPosY = mc.mcCntlGetDistToGo(inst, 1)

if CurrentPosX > LastPosX and CurrentPosY > LastPosY then
   --Do something
end

LastPosX = CurrentPosX
LastPosY = CurrentPosY


So the question is...If I put global variables LastPosX and LastPosY in the screen load script, will they be visible to the PLC script?  Or...Will LastPosX and LastPosY retain their values from scan to scan?  For instance, if I set LastPosX to 4.123, will it be nil on the next PLC scan or will it still be 4.123.

Thanks


Re: PLC Script and global variables
« Reply #1 on: June 30, 2017, 06:19:53 AM »
Global variables declared in the screen load script are indeed visible to the PLC and will retain their values as you require.

Allan