Sign in to follow this  
Guest Vorlin

XML odd problem..... Nick? Arnie? Gurus? HELP!

Recommended Posts

I'm no guru, but I've written a thousand+ line gauge that works nicely. I've run into an issue while trying to learn macros and I simplified it as far down as possible to try to pinpoint the issue... and it's become a nightmare because it's stripped down to the simplest form possible, all syntax should work, and it's as if the parser has flipped out.Jordan Moore was kind enough to help me out with the first part of it and that issue turned out to be that the parser was choking on:%(L:MyVar1,bool)%!5d!It was demanding that I read it off the stack, as in:%((L:MyVar1,bool) d 0 == ?)%!5d!Oh, I've long given up asking why on that one. That part works, I can use the second format no sweat. But it gets worse....Oh yea, it's gets crazier....I've never heard of this one before but I figure you all have.The text string line causes the parser to blow up if it's ONLY put into a different element than the one that the variable is set to 1 in. However, if it's nested into the same element, all is well. Combine both, and it works both ways.Tylenol is in the left hand drawer.... I need to get more after this one.Code examples with output:Example #1*******************1 (>L:MyVar1,bool)%((L:MyVar1,bool) d 0 == ?)%!5d!*******Result is 1 in the panel... all is well.*******************Example #2*******************1 (>L:MyVar1,bool)%((L:MyVar1,bool) d 0 == ?)%!5d!%((L:MyVar1,bool) d 0 == ?)%!5d!*******Result is 1 over 1 in the panel... all is well.*******************Example #3*******************1 (>L:MyVar1,bool)%((L:MyVar1,bool) d 0 == ?)%!5d!I am here.*******Result is nothing. Parser dies silently.*******************9 hours of frustration.... any insight into why it's refusing to work unless the text and value setting are in the same element would be appreciated. As you know, it's just not possible to have the text elements and the value manipulations in one element all the time.Thanks,VorlinHC070NC_Vorlin *CP* on Hover Control

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

Hi,1 (>L:MyVar1,bool)Is firing constantly, so what is the use, always 1.I am here.Does text show up when leaving the other elements out?Did you try:%((L:MyVar1,bool))%!5d! Jan"Beatus ille qui procul negotiis..."

Share this post


Link to post
Share on other sites

Hello Vorlin,First of all, ((L:MyVar1,bool) d 0 == ?) is dangerous to use because it lacks of one more value to compare properly. It happens in this case that it will always return MyVar1 value, but things would be different if there is a hidden stack value carried over from former code. Indeed, better is to use %((L:MyVar1,bool))%!5d!as Jan recommended.Other thing,""As you know, it's just not possible to have the text elements and the value manipulations in one element all the time.""Again, you have to be carefull when using and commands within the same , because, no matter the order it is positioned on, will execute always AFTER the part, and it could lead to wrong values especially when working with the same LVar in both commands.For example:1 (>L:MyVar,enum) (L:MyVar,enum) ++ (>L:MyVar,enum)%('Hello' 'Goodbye' (L:MyVar,enum) 1 == ?)%!s!'Goodbye' will never show because (L:MyVar,enum) ++ (>L:MyVar,enum) is being executed AFTER the command and reset again to 1 in the first element.All this said, your example #3 should work fine. Did you check whether the gauge loads ok inside Internet Explorer?Tom

Share this post


Link to post
Share on other sites

I'll answer the points made in replies, then I have a general question for you all.***Jan:Thanks. I haven't tried it yet but ((L:MyVar1,bool)) instead of (L:MyVar1,bool) looks familiar for some reason. So many tutorials, they all get run together in the brain. I have a feeling that using double parens may straighten it out.***Tom:"((L:MyVar1,bool) d 0 == ?) is dangerous to use because it lacks of one more value to compare properly..."I can see your logic and you make good sense. Some of us have found that the above is the only way to force a variable to be called properly and I think it may be more cases of the single vs. double parens that Jan pointed out above. I'll talk to some others about that and see."... will execute always AFTER the part,..."Never knew that. Though, now that you pointed it out, it becomes obvious why it could create issues. I understood your example perfectly, thanks. (Though I thought that true was forelast and not fore-forelast... but I never did try using the ternary operator as a stright if statement so maybe I have it backwards.)Example 3 worked fine in MSIE but not in FS9... again, I think it may be the need for double parens in a string even when displaying only a single value. That does seem familiar but I can't remember from where.***Ok, this seems like the best place to ask a question I've been talking to a lot of others about. Here goes:Is there a standards guide ANYWHERE? Arne did point out the rules for spaces in IF statements, but Select and Case seem to be hit or miss and macros are totally undocumented AFAIK and it takes hours of trial and error to see where they will and won't work... and sometimes you never do understand why.By a standards guide, I mean something like the following:(Info in text paragraphs could include) "... will execute always AFTER the part,..." (As well as other things we all would do well to know.)Coding examples could look like (spaces shown with a '*' ):This will work:*(L:Var1,bool)*if{**0*(>L:Var2,bool)*}*This will NOT work (due to insufficient spaces after '{' ):*(L:Var1,bool)*if{0*(>L:Var2,bool)*}*...or...Good string syntax: %((L:MyVar1,bool))%!5d!Bad coder, no donut. You forgot the double parens: %(L:MyVar1,bool)%!5d!Also, rules regarding macros? How about the differences between if statement syntax in values, text colors and strings? Or things that will cause a Select/Case tree to self-destruct? The scopes of s0 / l0, G:Vars and L:Vars were nicely covered by Arne... but what's the scope of a macro? Does anyone even know? I know that I can't answer ANY of the above questions... and I've read every tute I can find, plus the Panels and Gauges SDK.There is so much we could do with XML... but we're spending 80-90% of our time fighting syntax issues and problems that have become known as "just one of those things" because so very few people know the rules. The rest of us are wasting tremendous amounts of time trying to figure out how to make the tool (XML) work properly rather than using that XML tool to create awesome stuff for FS9.I don't think that's what MS had in mind when they made XML gauges possible... but we need to know all the ins and outs of how to use this very unusual implementation of XML before we can really put it to work and take FS9, or FSX, to the next level.Thanks for any and all help. If you guys have any rotary wing issues or want to learn to fly our way, just come on by! It's free and we're a really friendly crew!ScottHC070NC_Vorlin *CP* on HoverControl (www.hovercontrol.com)

Share this post


Link to post
Share on other sites

Scott,I'll try to clarify a bit:- "single vs. double parens" in Actually this is the real meaning: %( whatever )%etcetc tells the compiler that what is between parens is a stack area, where any kind of operations can be made; like in ...stack...If you use a LVar - which must be written (L:Var,unit) - inside that structure, there is no real "double parens" but instead the LVar's own parens are added to the syntax - %((L:Var,unit))% More examples: %((L:MyVar,number) 5 +)% shows MyVar value plus 5%(12 12 -)% shows 0And spaces dont't count providing there is at least one between each stack element. Open and close parens %( )% are NOT considered part of the stack in this case, due to the special treatment command has inside FS XML, but beware they are needed in other situations-more later.For example, %( (L:MyVar,number) 5 + )% is perfectly valid- Your questions:""Is there a standards guide ANYWHERE?"" Appart from Arne and Nick's wonderful tutorials, I think there is not. But if you do a search through this forum, you'll see most of your doubts have been discussed before.""Coding examples could look like (spaces shown with a '*' ):""The compiler distinguish stack's components (values and operators) when they are separated by AT LEAST one space. This includes the conditional if{ / els{ and the closing } Local vars (L:Var,unit) follow this rule: the compiler understands a stack position contains an LVar when the unit is followed by a parenthesis WITHOUT SPACES, and includes an open parenthesis, a L: sign and a comma.So this would be recognized as valid ( L:MyVar,unit) (L:MyVar, unit) ( L:MyVar, unit)And this won't (L:MyVar,unit )""Also, rules regarding macros? How about the differences between if statement syntax in values, text colors and strings? Or things that will cause a Select/Case tree to self-destruct? The scopes of s0 / l0, G:Vars and L:Vars were nicely covered by Arne... but what's the scope of a macro? Does anyone even know? I know that I can't answer ANY of the above questions... and I've read every tute I can find, plus the Panels and Gauges SDK""As I stated above, all this stuff have been already treated here, and I'm sure you'll find your answers if you do an advanced search covering those specific points you're interested in.""There is so much we could do with XML... but we're spending 80-90% of our time fighting syntax issues and problems that have become known as "just one of those things" because so very few people know the rules. The rest of us are wasting tremendous amounts of time trying to figure out how to make the tool (XML) work properly rather than using that XML tool to create awesome stuff for FS9.""Indeed there is much to do...even the most complex aircraft systems' logic can be simulated in XML. But it requires a good understanding of its basic principles and functioning, what means nothing but TIME, TEST and TEST and TEST... The gap in XML knowledge between you and me exists only because I started testing BEFORE than you. Got the idea? :-)Regards,Tom

Share this post


Link to post
Share on other sites

Got the idea LOLAt least you've helped me narrow the search for answers to this forum... before that, I was using google. That and it helps knowing that these things have answers at all! lolThanks,Scott

Share this post


Link to post
Share on other sites

Personally, I find C, C++ and GDI+ far less confusing... At least it's well documented! ;)However, be of good cheer. A little birdy whispered in my ear and led me to suspect strongly that there will be a nice WYSIWYG XML Editor coming soon to an FS near you... ;)

Share this post


Link to post
Share on other sites

I had exactly the same problem as you although the code was a bit different. i couldn't get an L:Var value to "stick" when used in a separate element. See the topic called "Fake magneto gauge". Tom gave a solution to that which amounted to putting "d" in my value line, as you did. However, you will note in the code for my fake magneto gauge that I DID have double Parens and it DIDN'T pass out my L:Var for further use.I'm a newcomer to XML gauges, and it appears that the language we use for gauges etc. is a Microsoft creation for FS not a Standard implementation of XML. If their SDKs are anything to go by, any FS-XML User manual would be poor to awful anyway. As a Technical Writer by profession, I could write a simple to understand user manual, but I would need someone beside me who can write the stuff and make it work.Peter

Share this post


Link to post
Share on other sites

I think everyone in this thread is well aware of this, but others who read it may not be."...it appears that thelanguage we use for gauges etc. is a Microsoft creation forFS not a Standard implementation of XML..."It's important to remember that XML is really little more than creating a schema to tell the parser what your custom tags mean and then writing your document using your own tags that you made up.What we all refer to as "XML" in this case is not the XML itsef, but rather the instructions to the stack. The parts of our code that do things are not XML, they're instructions... the XML itself is really the tags and the structural relationship of the data in those tags to other data in other tags within the document.The XML is easy... the syntax for stack instructions is anything but easy and it can vary depending on the conditions you're implementing the instructions under. IE:If statments are written differently for , and when they're used within the Color attribute of . This has been mentioned many places. Oh, you want to know *how* each implementation needs to be written? Well, if you find out then be sure to let me know! LOLI swear, you'd think someone at SDK development would make an XML SDK that covers all this stuff for gauges and scenery. They should. Anyone know how to contact the people who could get that done? Do they have a feedback forum or email?Scott / Vorlin

Share this post


Link to post
Share on other sites

>I swear, you'd think someone at SDK development would make an>XML SDK that covers all this stuff for gauges and scenery.>They should. Anyone know how to contact the people who could>get that done? Do they have a feedback forum or email?You will have a professionally written and well illustrated "XML SDK" at or about the same time that FSX is released.ACES has a fulltime, professional, technical publications writer who's sole responsibility is writing all of the SDKs for FSX. I've met and talked with him already... ;) He's quite a witty and charming person, and I'm confident you will all enjoy his approach.

Share this post


Link to post
Share on other sites

Excellent Bill, thanks.I'm currently compiling all the info I have into a guide format for my own use and the use of a few friends. Since it references posts of many other people, I only claim credit for gathering the info that's publicly available. It's already becoming quite a project.One thing I ran into was Jon's (Varmint007) tutorial on macros. In it, he states:"One can also use another function as an argument."I almost fell out of my chair when I read this. If this is possible, there should also be a way to trigger a macro conditionally, depending on the result of an IF or structure.And once we can do that, we can kiss limitations goodbye because we can use XML to do almost anything.Please, please pass on to him the importance of clearly and thoroughly documenting macros including their scope and how to call them from within every possibility be it VALUE, IF, CASE, another macro or whatever.Once we understand that, gauges and many other parts of MSFS can be taken to mind boggling levels.ThanksScott / Vorlin

Share this post


Link to post
Share on other sites

Scott,>One thing I ran into was Jon's (Varmint007) tutorial on>macros. In it, he states:>>"One can also use another function as an argument.">>I almost fell out of my chair when I read this. If this is>possible, there should also be a way to trigger a macro>conditionally, depending on the result of an IF or > structure.>If you'd take the time to investigate, in these threads you'll find examples of macros:Easy macro(s):http://forums.avsim.net/dcboard.php?az=sho...ing_type=searchIntermediate macro(s) http://forums.avsim.net/dcboard.php?az=sho...ing_type=searchAdvanced macro(s)http://forums.avsim.net/dcboard.php?az=sho...ing_type=searchNow, this is important and I can't emphazise it more:Macros are NOT functions but code snippets, the same as literal replacements of text (that's why they are called "macros" :-)) Despite its common use may lead to think they are like functions, once you start to deal with some complex ones you will notice that they don't support most of the very important characteristics of functions. Ie their code cannot be isolated from the calling code, they cannot deal with any kind of "Local" vars, and they cannot help to make the final assembled code smaller.In those advanced cases, a careful analysis of the stack composition should be done to avoid wrong results because of hidden values left on the stack, overwritten registers, (s0/l0), and so many other complexities.Tom

Share this post


Link to post
Share on other sites

Tom,Sorry about my loose usage of the term function LOL.Yes, I do realize that there can't be true functions in XML. Also, nothing in XML is coding in it's true sense, it's scripting. I had a long conversation with a professional coder about the differences about a week ago. I used to do a lot of stuff with Macromedia Flash AS1, which is another interpereted scripting language.What I like about using XML rather than C++ is it's a lot harder, though certainly not impossible, to crash FS9 if you make a mistake. Also, XML won't cause a BSD the way a major goof with C++ could.I've been digging around with several search terms and every time I change a term, other threads pop that didn't show before. Thanks for the links! All the info needed is definitely out there somewhere, it's simply a matter of ferreting it out... and that's painstakingly slow sometimes. That's why I'm trying to gather everything I can find into my own reference document.Thanks,Scott / Vorlin

Share this post


Link to post
Share on other sites

Ok...I just took a look. Easy and Intermediate were easy enough to understand but it revealed that I need to memorize stack operation syntax such as sp0 and << and such.I should have paused there LOL.Things were challanging until I hit your post in the advanced thread:"HOW TO ORDER LVAR VALUES FROM MIN TO MAX - AN EXAMPLE"Wow Tom... I never knew that my head could spin all the way around like that! I'm going to go eat and rest until my brain stops smoking!Thanks again!Scott / Vorlin

Share this post


Link to post
Share on other sites

Ok, I've so over-simplified this it's insane. I am beginning to believe that there is something wrong with my computer because this has all started since putting in XP SP2 and installing MS's "Visual Web Developer 2005 Express Edition".Here's a dandy for you. I've tried all sorts of syntaxes, nothing seems to help. Please try this code in a quick sample gauge and see if it works for you... which would tell me that the problem is in my computer, not my writing.***With the comments in, it displays fine. Take the comments out and I get a very quick flash of some sort of dialogue box as the flight is loaded but I can barely even see that it flashes, forget about reading it. The gauge itself is then blank.***<?xml version="1.0" encoding="UTF-8"?>(G:Var) 0 ==%('Hello World')%!s!***I just can't make it any more simple... and nothing I do to change the syntax of how I set (>G:Var1) seems to help.I'm baffled... any ideas? Please?Scott / Vorlin

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