Initialized Variable Issue?


#1

1) Give a description of the problem
Is this a bug? I was fighting a piston and finally figured out that this was the problem.

I have a variable that I initialize to a constant. What I wanted to do was have that initial value every time the piston initially starts, but any changes that are made within the piston are preserved in that run of the piston.
But what happens is that if I make a change to the variable, then do a Wait statement, then the variable reverts back to the initial value. Is this the expected behavior?

4) Post a Green Snapshot of the pistonimage
Here’s an example.

5) Attach any logs (From ST IDE and by turning logging level to Full)

image

REMOVE BELOW AFTER READING
If a solution is found for your question then please mark the post as the solution.


#2

When you use a WAIT period longer the ~3 seconds, webCoRE sets a timer to re-initialize your piston. Whether or not it’s a bug… I’m not sure, but there’s a relatively simple way to work around it in your piston.

Don’t set a value for your variable where variables are defined.

Define a boolean variable called waitActive

IF waitActive is false
THEN
Set variable ctr = 0

Every minute
Log info…
Set variable waitActive = true
Wait 5 seconds
Log info…
Wait 5 seconds
Log info…
Set variable waitActive = false