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

What does "d" do in this visibility condition?

<Visibility>(L:page_vis, number) 3 == d (A:Circuit General Panel On, bool) (A:Circuit Avionics On, bool) &amp;&amp; &amp;&amp;</Visibility>

I adapted this from the CRJ PFD I think it was, trying to come up with a way of cycling through some pages of data. It works fine like this but not without the "d". Further down the gauge I have some rectangles (buttons) that change color according to the same visibility conditions (selected page) but that one doesn't work with the "d":

<FillColorScript>'#660000' '#333333' (L:page_vis, number) 3 == (A:Circuit General Panel On, bool) (A:Circuit Avionics On, bool) &amp;&amp; &amp;&amp; ?</FillColorScript>

I get (I think) from the SDK that the d "Duplicates the value that is on the top of the stack". What on earth does that mean and how does it relate to what I'm doing here? What do I get on the stack from L: page_vis, number) 3 == for example? If L: page_vis equals 3 does that mean I get a "1" (True) on the stack? In that case I'd assume I'd get a 1 from the general panel on and circuit avionics on as well and I'd interpret the overall condition like:

IF condition_a equals 1 AND condition_b equals 1 AND condition_c equals 1 - then the object is visible.

I don't get why I need to duplicate that first "1" if I'm even remotely understanding what's going on here? Obviously I'm not! :)


Resource contributor

XML uses Reverse Polish Notation for it's math, and that's what the stack is for. Think of the stack as a vertical conveyor belt of values. You can only add to or remove values from the very top of the conveyor belt. When you add one, the rest get pushed down one spot. When you remove one, they move up one. Your code currently does this to the stack:

(L: page_vis, number) 3 == ..... add this value (True/False) to the stack.
d ..... add another of these True/False values to the stack.
(A:Circuit General Panel On, bool) ..... add this value (True/False) to the stack.
(A:Circuit Avionics On, bool) ..... add this value (True/False) to the stack.
&amp;&amp; ..... remove the top two values from the stack ((A:Circuit General Panel On, bool) and (A:Circuit Avionics On, bool)) and test if both are True. If so, it's True, if not False. Add that to the stack.
&amp;&amp; ..... remove the top two values from the stack (the result of our first AND statement and the d True/False) and test if both are True. Return that value (True/False) to the Visibility statement. If True, it's visible, if not invisible.

What the d statement did was leave the original (L: page_vis, number) 3 == True/False value on the stack. Whether this is retained after the </Visibility> tag I do not know, but that's the difference.


Resource contributor
Indeed the "d" symbol does duplicate the top entry of the stack, which after an evaluation might need to be repeated for a subsequent task.

For example, in this bit of script I'm evaluating the position of the left mixture lever, and setting the value of my custom L:variable for the left lever. However, because I wish to also apply this to the right lever as well, I use the "d" symbol:
        (L:ConditionLeftX, position) s0 0 !=
        (L:GENERAL ENG MIXTURE LEVER POSITION:1,enum) (M:X) l0 &lt;
        if{ 2 + 100 min } els{ l0 (M:X) &lt; if{ 2 - 0 max } }


Resource contributor
What the d statement did was leave the original (L: page_vis, number) 3 == True/False value on the stack. Whether this is retained after the </Visibility> tag I do not know, but that's the difference.

That is correct. And the stack's composition is carried on to the next sequential script in the chain of <Element> objects.
For example:

  <Visibility> 1 </Visibility>  ==> VISIBLE
  <Visibility>  </Visibility>  ==> NOT VISIBLE

  <Visibility> 1 d </Visibility>  ==> VISIBLE
  <Visibility>  </Visibility>  ==> VISIBLE

  <Visibility></Visibility>  ==> VISIBLE
  <Visibility>  </Visibility>  ==> NOT VISIBLE

Element2 is not visible because the stack is coming empty from Element1 and its own script is empty as well, then returns 0 to the <Visibility> condition.

Element4 is visible because the stack contains 1 carried from Element1 so, despite its own script is empty, returns 1 to the <Visibility> condition.

Element5 is visible because <Visibility></Visibility> are ignored, the same as not to write them out on the code. Then with no <Visibility> condition it is always visible. Element6 is not visible because the stack and its own script are empty.

For FS9 syntax make it <Visible> and the same rules apply.

I must have removed a space I shouldn't have or added an extra one or something the first time I tried removing the d. I just went through and stripped all the "d's" out again and the gauge works fine, lol.

It was actually the CRJ MFD where I got this (line 37 in the gauge if anyone wants to look at it). I still don't understand what they needed the d for either but then they're calling a bunch of GPS macros below that so maybe it has something to do with that somehow?

Tom G thanks for the explanation of the stack, that's more or less how I understood it but the conveyor belt analogy helps a lot. One thing I've never been clear on, is there one stack all through this gauge that we keep piling numbers onto or does each object in the gauge have it's own stack? ie. a stack for the <visibility> condition then we go down and calculate horsepower in the next <element> for example with <GaugeString>%((A:Recip Eng1 Brake Power,watt) 745.69987 /)%!3.1f!</GaugeString> which is nested inside the first element (the engine data page in this case) with the visibility condition. Does the horsepower calculation go onto the same stack we just used for visibility somehow or does it start fresh with a new stack for the <GaugeString> with the watt value at the bottom?

Bill's use of "d" makes sense to me BTW where he's duplicating the value of the left lever to the right.