How appropriate : FSX XML "sintax" -- rofl![]()
Well, I tried with "syntax" but the message wouldn't upload


At least Weescotty's one was correct
Tom
Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.
By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.
How appropriate : FSX XML "sintax" -- rofl![]()



Am I missing something or is the XML case statement next to useless?
OK you can set what values get returned but only on values supplied to it that are 0 1 2 3 etc?
Am I missing something or is the XML case statement next to useless?
OK you can set what values get returned but only on values supplied to it that are 0 1 2 3 etc?
Seems very inflexible.
eg in other languages -
CASE x
x = 2 then ......
x= 10 then ......
x = 12 then ......
But in XML only (if I read it correctly)
x = 0
x = 1
x = 2
etc.
Tom,Well, case operator can be very useful despite its own limitations, as you pointed out, that are related to the special meaning it has in XML code; very different of what is the usual in languages like C or Basic.
In other languages, CASE is a conditional operator that forces a jump to different memory blocks as a result of an evaluation; but in XML case is a stack "popper" that will extract-and-discard as many values as its operand indicates, taking the first one available after the operation.
From your own example:
x = 0 pop and use directly, no discard
x = 1 pop-and-discard one, pop and use
x = 2 pop-and-discard twice, pop and use
Up to 28 values can be popped from the stack using this method (x=0 to x=27)
Tom
Tom,
thanks for the explanation !
It's interesting to understand the goings on behind the cooking receipe. And there may be rare cases where that understanding could save from a lengthy troubbleshooting session.
Thanks.
Thanks for the explanation, can't see me using it though, its not flexible enough.
Well, case is one of the most powerful operators in FS XML scripts. Though taking plenty advantage of it may demand certain skills in XML programming.
Tom
Well, case operator can be very useful despite its own limitations, as you pointed out, that are related to the special meaning it has in XML code; very different of what is the usual in languages like C or Basic.
In other languages, CASE is a conditional operator that forces a jump to different memory blocks as a result of an evaluation; but in XML case is a stack "popper" that will extract-and-discard as many values as its operand indicates, taking the first one available after the operation.
From your own example:
x = 0 pop and use directly, no discard
x = 1 pop-and-discard one, pop and use
x = 2 pop-and-discard twice, pop and use
Up to 28 values can be popped from the stack using this method (x=0 to x=27)
Tom
Slight problem changing G:Vars to L:Vars (for an AI aircraft)
The L:Var can be either 0,1, or 2
So I have been using -
(L:MY_NAME,number) - to read the L:Var
0 (>L:MY_NAME,number) - to set the L:Var
But it doesn't appear to be working.
I am guessing it might be the number part of the code, seen number,enum etc used.
That's a valuable description. It suggests that all the "case" expressions are evaluated - not just the one that's actually selected?
I must have misunderstood your post #24 "Up to 28 values can be popped from the stack using this method (x=0 to x=27)" Does it push the expressions onto the stack as strings then pop the strings and only evaluate the selected one to get a value?No, there is no evaluation of the expressions at all, only their extraction following the logic related to the formula in post #26
I must have misunderstood your post #24 "Up to 28 values can be popped from the stack using this method (x=0 to x=27)" Does it push the expressions onto the stack as strings then pop the strings and only evaluate the selected one to get a value?
[I]case= [/I]
pop(3) =
i[0]=7
i[1]=9
i[2]=8
push(1) =
i[1] = [B]9[/B]
23 5 3 + 3 3 * 4 8 + 5 - 3 1 case +
+ - 1
* 8 5 3
+ 3 4 -> 12 -> [COLOR="Red"]7[/COLOR]
3 3 -> 9 9 [COLOR="Red"]9[/COLOR]
5 -> 8 8 8 [COLOR="red"]8[/COLOR]
25 25 25 25 25
But it must. take your own example
Code:23 5 3 + 3 3 * 4 8 + 5 - 3 1 case +
This creates a stack
Code:+ - 1 * 8 5 3 + 3 4 -> 12 -> [COLOR="Red"]7[/COLOR] 3 3 -> 9 9 [COLOR="Red"]9[/COLOR] 5 -> 8 8 8 [COLOR="red"]8[/COLOR] 25 25 25 25 25
This evaluates
5 3 + = 8
3 3 * = 9
4 8 + = 12
12 5 - = 7
to get the values of the case expression 8, 9, & 7. It then discards 7 & 8 and only uses 9.
]It suggests that all the "case" expressions are evaluated - not just the one that's actually selected?