Jump to content
Sign in to follow this  
Guest greenco

Using Case Statements

Recommended Posts

Guest greenco

I need some help with using " Case " statements in XML. I can find plenty of code that is used for displaying bitmap images, like Sample 1. I have not been able to use "Case statements" for any other purpose. I would like to know if it can be used to display "TEXT", like Sample 2. and can it also be used to display "Parameters" like Sample 3 ? greenco**************************************************************Sample 1(A:Flaps handle index,number) *****************************************************************Sample 2(A:Flaps handle index,number)Flaps UpFlaps NeutralFlaps Down ***************************************************************** Sample 3(A:Number of Engines, number)%((A:RECIP ENG1 FUEL FLOW, pounds per hour))%!5.2f!%((A:RECIP ENG2 FUEL FLOW, pounds per hour))%!5.2f!%((A:RECIP ENG3 FUEL FLOW, pounds per hour))%!5.2f!

Share this post


Link to post
Share on other sites

Hi ???,Two examples from my gauges:To display a string with a case:%('FULL' '20' '10' 'UP' 4 (A:FLAPS HANDLE INDEX,number) case )%!s! To use a case in a clickspot tooltip:GPWS State (%('Off' 'Temporarily Suspended' 'On' 'Test' ' ' 5 (G:Var1) case )%!s!)Cheers, Rob Barendregt

Share this post


Link to post
Share on other sites
Guest greenco

Thanks, but that is not what I was after. Is it possible to do something like this? This code is just an example and it does nothing, other than to demostrate what I want to do. I want to get a value (a number) from a parameter and depending upon what that number is, I want to display the contents of another parameter, in a gauge.(A:Number of Engines, number)%((A:RECIP ENG1 FUEL FLOW, pounds perhour))%!5.2f!%((A:RECIP ENG2 FUEL FLOW, pounds perhour))%!5.2f!%((A:RECIP ENG3 FUEL FLOW, pounds perhour))%!5.2f!greenco

Share this post


Link to post
Share on other sites
Guest dko60202

According to the DTD, and your and my experience, the tag only works for images.The expression parser does have a case operator, as shown in Rob's sample, and there is a different {case} structure that can be used inside s. I'd use that one in your case; there's some examples in the beech_baron. I'd whip up an example, but I'd get it wrong, so I'll leave that to the experts here.Douglas

Share this post


Link to post
Share on other sites

There are two ways to display s dependant on some parameter. The first would be to write 4 nearly identical containing the full formats controlled by .. Too much writing. The second way follows. Controlled by (L:EngineDisplay, number).. 0=off, 1= ENG1, 2=ENG2, etc.. %((L:EngineDisplay, number))%{case}%{:1}%((A:RECIP ENG1 FUEL FLOW, pounds per hour))%!5.2f!%{:2}%((A:RECIP ENG2 FUEL FLOW, pounds per hour))%!5.2f!%{:3}%((A:RECIP ENG3 FUEL FLOW, pounds per hour))%!5.2f!%{:4}%((A:RECIP ENG4 FUEL FLOW, pounds per hour))%!5.2f!%{end}%Robs post shows how to change "fixed" items ( The above could work too ) donot know if his version would switch between variables, haven't tried.Regards,Roman(KGRB)


20AUG21_Avsim_Sig.png?dl=1  FS RTWR   SHRS F-111   JoinFS   Little Navmap 
 

 

Share this post


Link to post
Share on other sites
Guest greenco

Thanks RomanI can use your code to make it do what I was wanting. I gather that your code is another method to get around writing a lot of IF..ELSE statements. I have filed it away in my XML folder, for future use.Thanks againgreenco

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...