• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    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.

G:Vars

LOL I missed that.

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.

Maybe I can pick your brains on something else........
Been playing with an AI helo.
Already know how to do the hover etc.
Was thinking about the blades.
How to get a looping animation, without using tick18? Not sure if using the current times seconds * 6 * engine RPM would work.
Also on them stopping in a fixed place, had an idea of tieing the blades to the heading bug (ie blades are childs of the heading bug and the bug is animated for flight), then when the blades are stopped checking what heading it is at against the aircraft heading and moving them accoedingly. Do-able?
 
Last edited:
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?

Case is quite useful. If you've ever used the stock Garmin GPS 500 gauge that comes with FS9 & FSX, then you have used case when clicking the RNG toggle button to zoom in and out of the map display. Check out line 105 of the gps_500.xml gauge.

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

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

Teson1,
Thank you:) and to expand a bit the concept, FSX uses a formula similar to this one to decide how many pop-and-discard needs to command:

stack2 stack1 stack0 nCant Enum case

Pop(x) where x= (Enum >= 0 and Enum < nCant) * Enum

Then if Enum is any number outside this scope the last stack value (stack0) is returned by case operator.

Tom
 
Thanks for the explanation, can't see me using it though, its not flexible enough.

Going back to a few posts above RE: assigning the heading bug -

Is it even possible to assign the heading bug to an external part in FSDS, it's not in any of the drop down part names.

Failing that I would need to able to find what keyframe the animation was at (and have to animate 1 --> 360 degrees in 1 degree increments :( )
 
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 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

Lets me out then ;)
VBA, VBS, HTML, JavaScript, AutoIT, VB.NET, Tiny Basic - not a problem.
XML - Grrrrrrrrr
 
Last edited:
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 (&gt;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.
 
Last edited:
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

That's a valuable description. It suggests that all the "case" expressions are evaluated - not just the one that's actually selected?
 
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 (&gt;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.

Nothing seems to be wrong with your assignments, and number is a proper unit. Could be a syntax error in the code.


That's a valuable description. It suggests that all the "case" expressions are evaluated - not just the one that's actually selected?

No, there is no evaluation of the expressions at all, only their extraction following the logic related to the formula in post #26

Tom
 
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 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, expressions are actually evaluated by the parser and their result pushed onto the stack as words of bytes (I guess FS uses low level inline asm() functions for doing this).
I've found case operates a bit different -and complex- from what I first thought:

value2 value1 value0 x y case

Then case = Pop(x) store i(0 to x-1) Push i(y)

It first pops x members and saves them into an array of x elements (index 0 to x-1), then pushes the (y) element back to the stack, which becomes the first one available for either a math operation, a logical evaluation, etc.
If x < 0, i() array is null then i(y) is also null (0) so 0 is pushed to the stack becoming the first value available.
If (y>=x or y<0) then y=0 so value0 is the first one available.

A brief example:

23 5 3 + 3 3 * 4 8 + 5 - 3 1 case +

stack members:

1
3
7
9
8
23

Then

Code:
[I]case= [/I]
        pop(3) =
          i[0]=7
          i[1]=9
          i[2]=8
        push(1) = 
          i[1] = [B]9[/B]

Now, 1 and 3 were popped by case operator;7,9 and 8 were popped and 9 pushed back as a result of the operation, so the stack current composition is:

9
23

then + = sum operation = 9 + 23 = 32

which is the final result of the script's evaluation

And the anomalies:

12 23 28 25 2 -3 case + = 48
12 23 28 25 -2 2 case + = 25


Tom
 
We seem to have come full circle - the case statement does evalauate all its expressions but then discrads all but the selected one.
 
:confused: Again, case knows nothing about the stack members popped and pushed; they can be numeric or string values, whatever, case doesn't care at all. The only evaluation it does is with the x and y enum indexes used as operands. Unless you call push and pop actions an evaluation?

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

Now I see your confusion. Is the parser who evaluates the expressions, not the case operator. I stated this in post #35. At the moment case is called, the stack is already formed with the resulting values. In fact you could use another operation to get the same result as with case; for example:

4 2 + 5 2 * 8 3 1 case = 10
4 2 + 5 2 * 8 3 1 p p p r p = 10

Hope this now makes sense to you :)

Tom
 
Back
Top