Sign in to follow this  
Guest greenco

Using Case Statements

Recommended Posts

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
Help AVSIM continue to serve you!
Please donate today!

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

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

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)

Share this post


Link to post
Share on other sites

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