Initialize one time with Nz and Staticvar IS working fine

Oh, it's "mean" now to state the obvious.
What's next... ?

"next" depends on you!

By the way, this awaits to be counter-questioned:

Which is an expansion of this thread's 3rd post:

Do you want to tell something new about one time executed code or what?
Just in case you want to repeat it again it's been there already for years.

The wording "run once" already tells everything.

Via your printf line the information about whether statement is true is not stored in interpretation window.
Printf line in your code is executed and text is written just once during successful initialization but most of the time not viewable for human eye because code execution may have been too fast. On subsequent AFL runs that printf line of yours is not executed anymore.

In order to get visible information about whether code has been executed one time proper function to use inside such if statement is _Trace function. Same as printf or any other code inside that if statement it is executed just once in your code. But via _Trace written text is recorded (stored) in according text output window for human eye to be seen.

So yes, that's why it matters whether to use printf or _Trace functions.

Once again, use _Trace function.

PS: To erase static variables without code just restart AmiBroker.

Did not find anything new in that last post either!

Wow, that is countered with:

StaticVar persistence (set to False by default) already explained in the StaticVarSet function reference, like so:

persistent = If it is set to True then static variable will be stored in PersistVars.bin file when AmiBroker is closing and reloaded automatically on next startup, preserving the values of static variables between application runs). In addition to saving them automatically on exit, persistent static variables can be auto-saved at user-specified intervals using SetOption("StaticVarAutoSave", interval );

You certainly know that, a beginner might not.

Coming back to this thread's context, when a user executes a complex code ultimately to be put as "execute once", several re-tests might be required. So, while developing, just to reset one StaticVar you're suggesting to restart AmiBroker every time such a need arise. :clap:

Sure, already did in this post.

That good KB you mentioned introduces the concept of "execute once" but does not mention anything about StaticVarRemove. Think from a novice's perspective, who is beginning to learn AFL functions - might be unaware of StaticVarRemove.

Concern arose when incomplete information was posted and then questioned in this manner:

When a code is "executed once" using boolean value stored in a StaticVar which requires an edit, that StaticVar needs to be reset to False (again) by whatever means.

We need to always make sure complete facts are presented, isn't it? That's why below was posted earlier (way before this dabble and all):

Now it becomes laughable.
You seem to be a child.

No one is hindering you to do what you want.

Glad to see that wretched line under your Nose lengthened!

Yes at heart, I am!

Helps see the world better and learn every day.

The topic is solved in first reply. The rest is not needed at all