It looks like a common mistake made by people creating XML gauges is to use too many percent signs (%). For example, I saw this in a 3rd-party gauge recently:
%{if}%(On)%{else}%(Off)%{end}
The underlined percent signs are unnecessary, and the parser will try to translate the "On" and "Off" as an expression that can be calculated. Recall that "%( )" is used to calculate expressions; for example:
%((A:Eng1 Oil Pressure, PSF) 20 <)
would equate to TRUE or FALSE and could be used with the %{if} conditional above to conditionally display text.
Thus, the 3rd-party gauge should have used:
%{if}(On)%{else}(Off)%{end}
This above information is also covered in the SDK, an excerpt of which is pasted below:
The format of conditions (if, then, else, and case statements) in gauge strings is different from that in other scripts. In gauge strings use the %{if}, %{else}, and %{end} constructs to choose which text to display. Note that these keywords are case-sensitive and must be typed in lowercase. Also, there must not be a space between the ‘%’ and the ‘{‘. An if statement can be used without a corresponding else, in which case nothing is displayed if the result of the condition is false. The syntax for usage is one of the following:
PingBack from http://geeklectures.info/2008/01/14/xml-gauge-text-part-iii-mind-your-s-and-s/
Hi Susan, thank you for the clarification.
I believe the misunderstanding exists because of the mode a var value is commonly displayed:
%((MyVar) > 0)%!d!
It could be "separated" in
%((MyVar) > 0) and %!d!
So it's important to highlight also that
!operator! formatting must be preceeded by a % like
%!s! or %!02d! or %!3.1f!
I think this is not properly explained in SDK
Regards,
Tom
I have a Macro to set a color dependant on the RADIO HEIGHT of a Selected Aircraft
<Macro id="LowAltitudeBackgroundColor" Name="LowAltitudeBackgroundColor">
<MacroValue>%((C:ITrafficInfo:S:RADIO HEIGHT, feet) 100 <)%{if}0x801010%{else}0x101080%{end}</MacroValue>
</Macro>
---------
PROBLEM
<GaugeString>(@LowAltitudeBackgroundColor)</GaugeString>
displays either of the correct values, according to the "Radio Height"
but
<BackgroundColor>@LowAltitudeBackgroundColor</BackgroundColor>
placed just before the GaugeString line doe NOT result in the correct colour background.
It is "Rust Brown", no matter what the RADIO HEIGHT is setting the Macro result to.
"Driving me crazy" -- can you tell me what I am doing wrong please :)
Geoff_D
Hi
I need to set up a <Visible> statement that evaluates (A:GPS APPROACH APPROACH ID, string) against a set of pre-defined strings such as 'VOR 21' 'LOC 31' etc. Please could you help me with the syntax required for the string 'VOR 21'
Thanks
Peter
Great post, explained really well and I could really understand. Thank you.