Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: rrc1962 on June 28, 2017, 05:51:20 PM

Title: PLC Script and global variables
Post by: rrc1962 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


Title: Re: PLC Script and global variables
Post by: Fledermaus 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