# Save value on first occurrence in Animation Nodes

In this setup Random number defines Y position of Empty, which is shrinkwrapped-constrained to "Array of stairs".

I'd like to save Z value (orange circle) in memory, when the first positive number will be generated (green circle) and keep it until animation ends. And please, do not modify Random number node.

EDIT: I've added another attribute to workaround saving value from previous frame. Looks messy, but works.

Attributes can be stored in memory during the life time of the blender instance as described in this answer. In this particular case, the logic is as follows. We have two variables occurred, storedValue:
• If the current frame is equal to the start frame, reset storedValue to some initial value and reset occurred to False.
• If occured is False:
• Set storedValue to the value.
• Set occurred to True.
• @SergeL You also need to check if the variable already stored is positive, if it is positive, then you shouldn't change it. So you should do x > 0 as well and factor that. Makes sense? – Omar Emara Jan 9 '19 at 11:42