Static remain after Window closed

I have an additional window with a Method which contains a Static.
After I close this additional window, when I re-open it and I recall the Method, the Static keeps the value I assigned and is not re-initialised. Is it normal?
Doc Static : It is written " A Static variable is equivalent to a local variable declared by the Var statement but its value is retained between several calls of the method it is declared in."
Then, as Var are destroyed (free memory) when we close a window, I thought it was the same for Static.
Launch this small project WindowMethodStatic.xojo_binary_project.
Run it, Open Window2, click “update static” many time. Close this window2.
Re-open it, re-click “update static”, this is not 0 but the last value.

It should always keep its value unless re-assigned.
If you close the window it’s retained, thus the value should remain as-is.

Your quote just ended a little early:

“Also, all the instances of a given class share the same static values.”

It’s no different to a Shared Property other than you can define it in code instead of through the IDE.

1 Like

Thank you very much for yours answers.

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.