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

[FSX] XML Problem with if condition

Messages
19
[SOLVED][FSX] XML Problem with if condition

Hi all,

I want to make a light gauge, that goes on if the Kohlsman setting not equals the Sea level setting.
The problem is that I can't get the if condition working.
Here is my partial code:

Code:
<SimGauge.Element id="Element">
    <FloatPosition>100.000,40.000</FloatPosition>
    <Image id="dotbg.bmp" Name="dotbg.bmp">
        <Transparent>True</Transparent>
        <Bright>True</Bright>
        <Luminous>True</Luminous>
    </Image>
    <Element id="Element">
        <FloatPosition>0.000,0.000</FloatPosition>
        <Visibility>(A:SEA LEVEL PRESSURE, inHg) == (A:KOHLSMAN SETTING HG, inHg) ==
if{ 0 } 
els{ 1 }
        </Visibility>
        <Image id="reddot.bmp" Name="reddot.bmp">
            <Transparent>True</Transparent>
            <Bright>True</Bright>
            <Luminous>True</Luminous>
        </Image>
    </Element>
</SimGauge.Element>


Can someone please help with the IF statement?

Thanks in advance,

Regards,
Jacob.
 
Last edited:
I think you've got an 'equal to' too many, Try;
Code:
<Visibility>(A:SEA LEVEL PRESSURE, inHg) (A:KOHLSMAN SETTING HG, inHg) == if{ 0 } els{ 1 }</Visibility>
 
I think you've got an 'equal to' too many, Try;
Code:
<Visibility>(A:SEA LEVEL PRESSURE, inHg) (A:KOHLSMAN SETTING HG, inHg) == if{ 0 } els{ 1 }</Visibility>

Sorry, does not work.

I tried an example from the default 737-800 gauge:

Code:
<?xml version="1.0" encoding="UTF-16"?>

<SimGauge.Element id="Element">
    <FloatPosition>100.000,40.000</FloatPosition>
    <Image id="dotbg.bmp" Name="dotbg.bmp">
        <Transparent>True</Transparent>
    </Image>
    <Element id="Element">
        <FloatPosition>0.000,0.000</FloatPosition>
        <Visibility>(A:SEA LEVEL PRESSURE, inHg) == (A:KOHLSMAN SETTING HG, inHg) if{ 1 } els{ 0 }</Visibility>
        <Image id="reddot.bmp" Name="reddot.bmp">
            <Transparent>True</Transparent>
            <Bright>True</Bright>
            <Luminous>True</Luminous>
        </Image>
    </Element>
</SimGauge.Element>

but still doen't work...
 
Code:
<Visibility>(A:SEA LEVEL PRESSURE, inHg) (A:KOHLSMAN SETTING HG, inHg) == if{ 1 } els{ 0 }</Visibility>

Does this work?
 
Code:
<Visibility>(A:SEA LEVEL PRESSURE, inHg) (A:KOHLSMAN SETTING HG, inHg) == if{ 1 } els{ 0 }</Visibility>

Does this work?

Neither, the light is always off, so reddot.bmp is never showed.
Tried with digits in stead of variables. That works. It seems, that the variables are not evaluated well in flightsim.
I'll working on it.
 
Last edited:
Rounding errors, probably. Sea Level pressure might be something like 29.92182 inHg, and Kohlsman something like 29.917782 inHg. The numbers are not equal, but in typical gauge readouts, they may be rounded to 2 decimal places and appear the same.

Your formula

(A:SEA LEVEL PRESSURE, inHg) (A:KOHLSMAN SETTING HG, inHg) ==

will likely always return 'not equal'.

Bob
 
Rounding errors, probably. Sea Level pressure might be something like 29.92182 inHg, and Kohlsman something like 29.917782 inHg. The numbers are not equal, but in typical gauge readouts, they may be rounded to 2 decimal places and appear the same.

Your formula

(A:SEA LEVEL PRESSURE, inHg) (A:KOHLSMAN SETTING HG, inHg) ==

will likely always return 'not equal'.

Bob

You are so right Bob!
Thank you very much for this tip.
I changed the setting from HG to MB of both and it works like a charm!

Kindly regards,
Jacob.
 
I changed the setting from HG to MB of both and it works like a charm!

You might give this a try for the heck of it:

Code:
    <Macro Name="Round2">d flr s0 - 100 * near 100 / l0 +</Macro>

and

Code:
<Visibility>(A:SEA LEVEL PRESSURE, inHg) @Round2 (A:KOHLSMAN SETTING HG, inHg) @Round2 == if{ 1 } els{ 0 }</Visibility>

Also, you should have run into the same problem using millibars... one will be 1013.0625 and the other 1013.2500, for example. Again, not equal...

Bob
 
Last edited:
You might give this a try for the heck of it:

Code:
    <Macro Name="Round2">d flr s0 - 100 * near 100 / l0 +</Macro>

and

Code:
<Visibility>(A:SEA LEVEL PRESSURE, inHg) @Round2 (A:KOHLSMAN SETTING HG, inHg) @Round2 == if{ 1 } els{ 0 }</Visibility>

Also, you should have run into the same problem using millibars... one will be 1013.0625 and the other 1013.2500, for example. Again, not equal...

Bob

Thanks very much Bob!
I changed it back to HG and with your macro it works great!

Jacob.
 
Back
Top