Jump to content
Sign in to follow this  
Guest grb

Printing contents of G and L variables in XML gauges......How to do?

Recommended Posts

Guest grb

HI folks.Does XML language allow one to display the contents of G and L type variables in XML gauge Text windows?Example: A:GROUND VELOCITY,knots) (>L:Var1,knots) %((L:Var1,knots))%!d!%In panel I do not see any background nor any digits....Of course if I replace the L:Var1 with A:GROUND VELOCITY in the string construct I see the velocity displayed in the text window.Thanks for any help. George

Share this post


Link to post
Share on other sites
Guest bartels

Just a guess,not tested: (A:GROUND VELOCITY,knots) (>L:Var1,number) ... %((L:Var1,number))%!d!%Arne Bartels

Share this post


Link to post
Share on other sites
Guest grb

Arne,Thanks for the imput/help. Doesn' work. I inadvertantly forgot the leading "(". At any rate, verbatim, per your code, I just get a "0", in the text field. Under value line I also tried:120 (>L:Var1,number) to see if it would assign 120 to the variable.I also tried: (G:me) 100 + (>G:me) to hopefully assign G:me the number. None of the examples work. I do know that I can assigne lets say (G:me) 1 , then while in a case statement on the value.........then display a given bmp image, based on if the blah ....blah.********* Of course if I do this in the print statement part: WORKS just fine.Bottom line is I seek how to assign various L or G variables somewhere lets say at the top of a file, then during in various elements, modify the value of the variables and use them an calculations and in print statements.At any rate, thank you for the suggestion.George

Share this post


Link to post
Share on other sites

Hi George,I think I understand what you want. Near the top of you code, try putting in an initialization block like so...(L:My Gauge Startup, bool) ! if{ (A:GROUND VELOCITY,knots) (>L:Ground Velocity, number) (A:Sim Variable 2, unit) (>L:My Variable 2, number) (A:Sim Variable 3, unit) (>L:My Variable 3, number) 1 (>L:My Gauge Startup, bool)}%((L:Ground Velocity,number))%!d!%Things to remember:(G:Var#) is a local variable and MUST be named (G:Var1) - (G:Var9) with NO UNITS. There is little reason to use (G:Vars) unless other gauges absolutely should not be able to see the value. I say 'little use' because if there's any complexity to your gauge you'll soon forget what you used them for since they cannot have unique names. There are applications, but unless you KNOW you need to use a local variable, stick with (L:Vars).(L:Any Name, unit) should be used in most cases. You must use the units "number", "enum", or "bool". There is also a "mask" unit, but you shouldn't be concerned with that.There's nothing you've asked to do that isn't done all the time - it's just a matter of syntax and understanding how the naming conventions work.--Jon

Share this post


Link to post
Share on other sites
Guest grb

Jon,Thank you for your help. OK. I literally used the code you show above.Does not work. May I ask you why the following will not work:Goal: assign variable a value of 100. Then have it show up in a print statememt:Where:(L:Me,number) 100 %(L:Me,number)%!5d!% RESULT;The background colored window does not even show up in the panel. If I was to replace the variable with some known aircraft event in the print statment, I will see it show up in the colored text window.There seems to be some problem with displaying the contents of a G or L type variable in a String contruct. I would think if the arguments given to the String argument where simply not appropriate for a given type variable to be displayed that at least one would see the background colored window show up. This is not the case. I don't see the background colored text window for this example.NOTE: If I where to modify the code to display some aircraft variable at least I get the colored background text window to show up regardless if the value is correctly displayed or not, due to incorrect formatting arguments to the print statement.Obviously I just don't know what the hell I am doing yet. Can you provide any insight into why the contents of L:Me cannot be displayed as shown here?Thanks,George

Share this post


Link to post
Share on other sites
Guest dko60202

George, I'm a newbie too, but a coupla things I noticed:Variable assignment should be:100 (>L:Me,number)It's hard to tell in forum postings, but it looks like you might have an extra ';' after the greater-than signString statement:%((L:Me,number))%!5d!%Note the double set of parens; I don't understand why, but they seem to be required.Douglas

Share this post


Link to post
Share on other sites
Guest bartels

As Douglas and Jon pointed out there are some slight problems with naming convention and general syntax. It is as usual RPN Syntax, double paranthesis in strings and most important you need either a proper background bitmap or some Size statements (kind of "invisible" background) to determine the startup size of the gauge. This works:(A:GROUND VELOCITY,knots) (>L:Me,number)%((L:Me,number))%!5d!%Arne Bartels

Share this post


Link to post
Share on other sites
Guest grb

Douglas,Thanks for your observances. OK. Firstly. the &gt actually stands for">" in the XML code. So for example, in my text editor I would write:100 (>;L:Me,number) where it is a semicolon after the greater then.The "&gt" in XML code as means greater then, and is used in test statements, e.g. if statement. The ">" sign, means to redirect, or in the context used here, assign some value to a variable.I believe, if you have "emotions" option turned on, that if you type a ">" sign in your message, that it will show up as a "&gt". So this is why some people simply write &gt when presenting code in this forum.Hope that is not confusing.In your second observation. Yes one as it appears in all working gauges, one should use a double paren before and after the variable within a print statement. I just have droped the second set inadvertantly when I wrote the code in the forum post.So that you do know, one can elaborate on what goes into the double paren area. For instance, lets say you wanted to assign a letter to a variable and then display it within the print statement. One way to do it would be as follows:%((L:me,number) 100 chr)%!s!%What would happen is the variable would be assigned a value of a hundred, which in ASCII stands for the letter "d". Then the "chr" operator would convert the numerical value in the variable into a ascii character, in this case the letter "d". So by convention in XML language one uses a double parentheseis set presenting them in a print statement. The result in your text window, would show the letter d.The issue is how can one create, assign G and L type variables in a gauge and then use them, e.g. in print statements throughout the gauge elements, and use them for calculations in other elements of a given gauge. Obviously, one can asssign and print the contents of a assigned G or L type variable when it is embedded within the print statement as illustrated above. But so far I have not been able to assign a G or L variable some numberical value for instance, and then later in another element of the gauge, display it's value in a text window. That is the solution I seek.But thank you for your hints. Good observations.George

Share this post


Link to post
Share on other sites
Guest grb

Thanks Arne,I try your suggestions. cheers,George

Share this post


Link to post
Share on other sites
Guest dko60202

Actually, George, I believe that in XML, as in HTML, the greater-than sign is written '>' NOT '&gt'. The semi-colon is part of the replacement. The assignment operator should not be followed by a semi-colon, as in '>;', which is incorrect. Same rules apply whether used as an assignment operator or a comparison operator; context determines how it is used, not the syntax.As others have mentioned, folks (myself included) set and display L: and G: variables all the time; it's just a matter of getting the syntax right (took me hours and hours of head knocking, myself, but I'm a slow learner :-) )Good luck!

Share this post


Link to post
Share on other sites
Guest bartels

Edit: see the other postArne Bartels

Share this post


Link to post
Share on other sites
Guest grb

Your so right. I hope Douglas reads your comments to me. So I don't mislead him. I must be getting to old, making to many mistakes of lately. Thanks.

Share this post


Link to post
Share on other sites
Guest grb

Yoooo Arne,Your code works fine! I then in the first element removed the aircraft variable being assigned to the L variable and simply did a:100 (>(L:Me,number)And 100 gets displayed in the text window! I also now realize that if one would do the following:(L:Me,number) 100 + (>L:Me,number)That each time the gauge is updated in the simulation, it would increment the L value by 100. So obviously one must be very careful as how they write such code. The next step is to work on initializing a number of variables in elements, then use them later on in the gauge for comparisons and calculations etc..Thanks all who have contributed to this post. I hope it will somehow help others that are wondering how to use variables in a global fashion within a XML gauge to do calculations and be able to display them.take are all,George

Share this post


Link to post
Share on other sites
Guest grb

Jon,I now realize that your code will probably work just fine. I had inadvertantly used the ">" sign instead of using a "&gt", then ";"symbol in your variable assignemt code. As you can see, after I tried Arne's example, esentially the same code constructs as your example,the L variable now displays correctly in the later print statement.Thanks for your help.George

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...