Share via


Conditionally Displaying Text in XML Gauges

I thought this might be of interest to some people out there:

You can use the %{if}, %{else}, and %{end} constructs to choose which text to display.  Note that if, else, and end are case-sensitive and must be typed in lowercase.  The syntax for usage is:

%(CONDITIONAL)%{if}TEXT TO DISPLAY IF TRUE%{else}TEXT TO DISPLAY IF FALSE%{end}

For example:

%( 1 )%{if}ON%{else}OFF%{end}

would give the following output:

ON

Whereas the following:

%( 0 )%{if}The value is true%{else}The value is false%{end}

Would yield the following output:

The value is false

NOTE: There must not be a space between the ‘%’ and the ‘{‘.

 

The if maybe be used without a corresponding else.  In this case, if the conditional evaluates to false, no text will be displayed.

Comments

  • Anonymous
    November 17, 2005
    Engauges:

    First of all let me thank you and the rest of ACES for sharing some of your insights with us.

    I will first apologize as this might not be the appropriate venue to ask a question, but at this moment I do not know where else to go.

    I am very new to XML coding and feel like a fish out of water.

    Well here it is:

    I am taking the basic XML code for the Fuel Selector Switch used in the DC3 which is as follows:

    XML CODE USED TO HELP SET UP THE NEW CODE (Movement is set as Key 0 = Off, Key 25 = Right, Key 50 =Left, Key 75 = Aux)


    <part>
    <name>lever_fuel_selector_DC30</name>
    <animation>
    <parameter>
    <code>75 0 0 25 50 50 0 7 (A:FUEL TANK SELECTOR 1,enum) case</code>
    <lag>100</lag>
    </parameter>
    </animation>
    <mouserect>
    <cursor>Hand</cursor>
    <help_id>HELPID_GAUGE_FUEL_SELECTOR</help_id>
    <tooltip_id>TOOLTIPTEXT_DC3_LEFT_FUEL_SELECTOR</tooltip_id>
    <callback_code>
    (A:Fuel tank selector 1,enum) s0
    <!-- off to right -->
    0 == if{ (&gt;K:FUEL_SELECTOR_RIGHT) }
    <!-- right to left -->
    els{ l0 3 == if{ (&gt;K:FUEL_SELECTOR_LEFT) }
    <!-- left to center -->
    els{ l0 2 == if{ (&gt;K:FUEL_SELECTOR_CENTER) }
    <!-- center to off -->
    els{ (&gt;K:FUEL_SELECTOR_OFF) }
    }
    }
    </callback_code>
    </mouserect>
    </part>

    The Changed code I have tried to implement is as follows (note the movement I want to achieve)


    NEW CODE WITH A SLIGHT MODIFICATION (MOVEMENT TO ACHEIVE Key 0 = left, Key 25 = Off, Key 50 =Right, Key 75 = Aux)


    <part>
    <name>lever_fuel_selector_o2a1</name>
    <animation>
    <parameter>
    <code>75 0 0 25 50 50 0 7 (A:FUEL TANK SELECTOR 1,enum) case</code>
    <lag>100</lag>
    </parameter>
    </animation>
    <mouserect>
    <cursor>Hand</cursor>
    <help_id>HELPID_GAUGE_FUEL_SELECTOR</help_id>
    <tooltip_text>Fuel Selector Rear Engine</tooltip_text>
    <callback_code>
    (A:Fuel tank selector 1,enum) s0
    <!-- off to right -->
    0 == if{ (&gt;K:FUEL_SELECTOR_LEFT) }
    <!-- right to left -->
    els{ l0 3 == if{ (&gt;K:FUEL_SELECTOR_RIGHT) }
    <!-- left to center -->
    els{ l0 2 == if{ (&gt;K:FUEL_SELECTOR_OFF) }
    <!-- center to off -->
    els{ (&gt;K:FUEL_SELECTOR_LEFT_AUX) }
    }
    }
    </callback_code>
    </mouserect>
    </part>


    Can you please help me figute out why I cannot get the part work as per my needs.

    I will understand if you cannot provide help.

    Thank you

    Jim
  • Anonymous
    November 17, 2005
    Jim - offhand, I don't see anything particularly wrong there, but I'm not really involved with the animation system side of FS. Have you posted your question to the appropriate forum(s) on avsim.com et al?
  • Anonymous
    November 17, 2005
    Hi Susan:

    I have posted the question at other sites and but missed AVSIM... in fact I cannot log into it for one reason or another (MY PC and AVSIM's cookies). The issue with modifing or placing the variables as needed actually renders the animation useless. But thanks for at least taking amoment to answer.. I think I will leave the animation as 0=left, 25=off and 50=right.... this will save me a lot of grief and time oh yes alse a few hairs in the process.

    Thanks

    Jim
  • Anonymous
    August 09, 2008
    If u wna find out what's wrong with it, double click the xml and it'll give u a hint of what's wrong