I am trying to initialize a variable during 1st run and wrote below code to test. It is not working (i.e. It is not executing printf statement inside IF). Appreciate your inputs.
That printed text inside your if statement is visible for a blink of an eye only.
Printf does not record text.
Use _Trace function instead to record messages. http://www.amibroker.com/guide/afl/_trace.html
So, you need to remove that StaticVar for the code inside it to be executed again. Also, learn the usage of * as mentioned in StaticVarRemove.
Having that said, do not keep that StaticVarRemove in your code all the time. That would be like shooting yourself in the foot and the intention of "Execute that Once" won't be served.
We do not know what OP is doing there or thinking.
Empty != Null
Empty (or "") applies to StaticVarSetText or StaticVarGetText like an empty string, and, Null applies to StaticVarSet or StaticVarGet kind of similar to should be a number instead NaN (Not a Number).
You seem to have reading problems.
Once again read first sentence of first post.
Then read second post of this thread in regards to visibility of text when trying to initialize one time.
I read that when you posted it, did not fuzz! However, since you insist, re-read and replying now.
Probably, someone here does need to revisit that good old printffunction reference.
printf and StrFormat behave identically except that printf writes output to the window, while StrFormat does not write anything to output window but returns resulting string instead.
That statement is not correct.
printf( string ) works, so does printf( "%s", string )!
P.S.
I knew @fxshrat - The Perfectionist, did not know turned to a virtual Ophthalmologist as well. Thanks for the advice, for now I can read well (especially stuff written between lines).
Just current text output (of current AFL run) is seen in interpretation window but no past one.
Interpretation window output is not keeping memory of old text output been printed within an 'if' statement returning true (single time). So most of the time you can't see it because execution is too fast and just being viewable within blink of an eye (re-read 2nd post of this thread once again). Text of if statement being executed before is not "recorded" there (not being kept in Interpretation window).
On the other hand _trace writes to debug viewer where (all) past recorded output can be viewed.
All records are kept there.
Thanks for the laugh.
As usual it is just repetition of already written code.
Whether adding chartID or not is up to the user of first post.
It is rather about making printf to output text kept in memory.
Now take another one hour or two ones to write long essay.
As mentioned printf behaves identically like StrFormat. Do not steer this to printf vs _TRACEF! This thread was never meant to be so.
If StaticVarSet inside an one-time executed code, unless reset, won't execute that inside code again. Does not matter whether you use printf or _TRACEF or _TRACE.
Sometimes, it is better to swallow rather than frantically throwing at others.
I wonder how you lost that old dignity of yours. Sorry, you're making fun of yourself!