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

XML code problem

Dave_W

Resource contributor
Messages
185
I've added two reference markers to an altimeter.

They will indicate an altitude value based on what the altimeter barometric setting is.

I want them to move only when I change the KOHLSMAN setting.

I made the below test code to see what happens when I change the KOHLSMAN setting. The code doesn't work correctly.
Code:
  <Element>
    <Select>
      <Value>
        (A:KOHLSMAN SETTING HG, inHg) 29.91 >= (A:KOHLSMAN SETTING HG, inHg) 29.92 &lt; AND  if{ 50 (>L:100s_ref_marker, enum) }       
        (A:KOHLSMAN SETTING HG, inHg) 29.92 == if{ 0 (>L:100s_ref_marker, enum) }
      </Value>
    </Select>
  </Element>

I load a default flight. The setting is the default 29.92. Instead of 0, the L:Var is set to 50. What have I messed up??

I have found that incrementing and decrementing the Kohlsman setting returns a value with a third decimal
place, e.g. 29.911, so that I won't use (A:KOHLSMAN SETTING HG, inHg) value == after I get past this.

Pressing the B key will set a two-place decimal. In this test case 29.92. The L:Var setting stays set at
50. But, shouldn't 29.92 == work to set the L:Var to 0 in this specific case? Or, is it not changing because
of whatever is wrong with the first line of code?

TIA
 
When the sim loads it defaults to 29.92 Also it might be an idea to declare your variable
(L:100s_ref_marker, enum) as zero initially and then only when you move the Kohlsmann knob the value will change.
 
Pressing the B key will set a two-place decimal. In this test case 29.92.

Actually not. That is a floating point value so we cannot know for certain its internal value; what we see is a representation rounded to the number of decimals used for displaying.
Therefore it is not secure to compare any fp value using == operator. Instead, use an integer version, for example 29.92 100 * int

Tom
 
Thanks guys.

Volo: I tried your suggestion. The FSX SDK says that "When a local parameter is first referenced, it is created and its value is set to zero." It didn't make any difference.

Tom: unfortunately for me, what you pointed out is why the first line of my code above works when I thought that it wasn't, in addition to why the == operator should not be used.

I found this thread today http://www.fsdeveloper.com/forum/threads/variable-comparison-and-number-formats.437253/

An idea I got somewhat from what Anthony31 said in post #5, I put this in a tooltip:
Code:
%((A:KOHLSMAN SETTING HG, inHg))%!f!
the default 29.92 returns 29.919870.

Edit: I ended up using (A:KOHLSMAN SETTING HG, inHg) 100 * near (>L:FormatKollsman, enum) from an idea I got that Tom mentioned in post #4 of the above referenced thread.
 
Last edited:
Thanks guys.

Volo: I tried your suggestion. The FSX SDK says that "When a local parameter is first referenced, it is created and its value is set to zero." It didn't make any difference.


From your code snippet it appeared that you had set the value immediately the variable was called. So try setting to zero or create an if{} based on the assumption that it is zero. It won't do any damage.
 
Back
Top