How To - Show Static Variables in AFL Watch Window

In Highlights of version 6.20, documentation states that debugger’s watch window supports display of static variables and expressions with static variables. However, during a debug session, the value displayed in the watch window for StaticVarGet(“myStaticVar”) is “The identifier is not a variable”. Can anyone provide clarification on how to display a static variable’s value (whether it is an array or a scaler)?

Use $myStaticVar (dollar sign before name)

From Release Notes (6.19:

Debugger: Watch window: added ability to display values of static variables in watch window - just append ‘$’ (dollar) prefix before static variable name

5 Likes
elapsed_000_start = GetPerformanceCounter( True );

tickerString = Name();
minInterval = ( Interval( 0 ) / 60 );
tickerInterval = tickerString + "_" + minInterval + "min_";

testingAvailability = StaticVarGet( tickerInterval + "limitFibLev" );

timeConsumption_000 = 0;
timeConsumption_001 = 0;

uniLookBack = 500;

Can anyone tell me why it doesn't show the value of the static variable CNH.JPY-IDEALPRO-CASH_1min_limitFibLev with the dollar sign prefix ?

I tested that the variable is available and exists in variable: testingAvailability and the value of variable tickerInterval is "CNH.JPY-IDEALPRO-CASH_1min_". But in watch window it says type: error and value: undefined variable for the static variable. Am I doing anything wrong here ?code_001 watch_001

Such variable names are not allowed anyway as they contain invalid characters.



FYI, AmiBroker now internally replaces invalid characters (within static and dynamic variables) to valid ones e.g . (point) converted to _ (underscore).


Now if you want to return static var name then do like this

staticvar_name = tickerInterval + "limitFibLev";
testingAvailability = StaticVarGet( staticvar_name );

and put staticvar_name to Watch window of debugger.

In addition you may use StaticVarInfo() function to output information of your static variables.

In addition to what @fxshrat wrote - you can display static variable using $ prefix in the watch window IF you replace all invalid characters with underscore.

Minus (dash) - is not allowed in variable name because - is arithmetic operator and watch window would interpret it as subtraction.

Thanks a lot (: That was me not remembering basic naming rules