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

FSXA <Visible> with <Text>

Messages
862
Country
indonesia
I'm doing an HSI gauge and I want to display the Nav1 or GPS ident depending on the position of the NAV/GPS switch. Sounds simple enough;

Code:
<!-- NAV1 /GPS Ident -->
<Element>
  <Visible>(L:Batt Av On,Number) 0.5 &gt;</Visible>
  <Position X="20" Y="32"/>
  <Text X="32" Y="16" Length="4" Font="Arial" Color="#00FF00" HorizontalAlign="LEFT" >
    <String>%( (A:GPS DRIVES NAV1,Bool) )%{if}%( (A:GPS WP NEXT ID,String) )%!4s!%{else}%( (A:NAV IDENT:1,String) )%!4s!%{end}</String>
  </Text>
</Element>

However, it doesn't display when I switch the Battery and Avionics on (L:Batt Av On). It does display after I've switched the NAV/GPS switch (either way).
I've overcome it with this;

Code:
<!-- NAV1 /GPS Ident -->
<Element>
  <Position X="20" Y="32"/>
  <Text X="32" Y="16" Length="4" Font="Arial" Color="#00FF00" HorizontalAlign="LEFT" >
    <String>%( (L:Batt Av On,Number) 0.5 &gt;)%{if}%( (A:GPS DRIVES NAV1,Bool) )%{if}%( (A:GPS WP NEXT ID,String) )%!4s!%{else}%( (A:NAV IDENT:1,String) )%!4s!%{end}</String>
  </Text>
</Element>

so it's not a major problem. But why doesn't the first method work?
 
Last edited:
I think it's because visible tags don't work with custom codes that use 0.5 as a reference.
Why not use the default avionics and battery. or my second method!


Code:
<!-- NAV1 /GPS Ident -->
<Element>
<Visible>(A:Circuit Avionics On, bool) (A:Electrical master battery, Bool) andand</Visible>
     <Position X="58" Y="0"/>
     <Failures>
       <SYSTEM_ELECTRICAL_AVIONICS Action="0"/>
     </Failures>
  <Position X="20" Y="32"/>
  <Text X="32" Y="16" Length="4" Font="Arial" Color="#00FF00" HorizontalAlign="LEFT" >
    <String>%( (A:GPS DRIVES NAV1,Bool) )%{if}%( (A:GPS WP NEXT ID,String) )%!4s!%{else}%( (A:NAV IDENT:1,String) )%!4s!%{end}</String>
  </Text>
</Element>


Code:
<!-- NAV1 /GPS Ident -->
<Element>
<Visible>(L:Batt Av On,Number)</Visible>
     <Position X="58" Y="0"/>
     <Failures>
       <SYSTEM_ELECTRICAL_AVIONICS Action="0"/>
     </Failures>
  <Position X="20" Y="32"/>
  <Text X="32" Y="16" Length="4" Font="Arial" Color="#00FF00" HorizontalAlign="LEFT" >
    <String>%( (A:GPS DRIVES NAV1,Bool) )%{if}%( (A:GPS WP NEXT ID,String) )%!4s!%{else}%( (A:NAV IDENT:1,String) )%!4s!%{end}</String>
  </Text>
</Element>

DG:rolleyes:
 
Last edited:
I think it's because visible tags don't work with custom codes that use 0.5 as a reference.

That doesn't make any sense. It doesn't matter what numerical value you use as a reference, because all that has to be on the stack at the end of the Visible tag is a boolean value, and using a < or > comparison works. I do that all the time for custom systems. Incidentally in your first bit of code you wrote "andand" which should probably be && or &amp;&amp; in FSX XML...;)
 
Last edited:
I was trying to eliminate the problem with L:Vars not being a bool 1 but a float 1 which doesn't exactly equal 1. As you know, the only reliable method is 0 !=.
I already tried the individual A:Vars but that didn't work either. I was just trying everything I could think of.

<Failures> will probably work, I'll try that.
 
Incidentally in your first bit of code you wrote "andand" which should probably be && or &amp;&amp; in FSX XML...;)

and && &amp;&amp; are all functionally identical...

as are

or ||

As for the bool condition, the only 100% reliable method is (L:MyVar,bool) !
 
I use "and" and "or" exclusively as it makes it SO much easier to read easily and interpret the logic...

e.g.:

Code:
      <!-- WARNING/CAUTION LIGHT -->
      (A:GENERAL ENG GENERATOR ACTIVE:1,bool) 0 ==
      (A:GENERAL ENG GENERATOR ACTIVE:2,bool) 0 == or
      (A:GEAR HYDRAULIC PRESSURE:1, psi) 100 &lt;  or
      (A:HYDRAULIC PRESSURE:1, psi) 100 &lt;       or
      (A:GENERAL ENG FUEL PRESSURE:1, psi) 1 &lt;  or
      (A:GENERAL ENG FUEL PRESSURE:2, psi) 1 &lt;  or
      (L:OxyQtyLow,bool) 1 ==                      or
      (L:FuelQtyLow,bool) 1 ==                     or
      (L:FuelOvrHeat,bool) 1 ==                    or

      if{ 1 (>L:MasterWarn,bool) }
      els{ 0 (>L:MasterWarn,bool) }
 
Last edited:
I like the simple andand....

But if you go 3 tasks i go...... &amp;&amp; &amp;&amp; &amp;&amp;

I know that it makes no sense that it's the 0.5. But 0.5 does not make sense for a switch on and off. I forgot to add the quotation. (L:MyVar,bool) !

I have come across this issue before and it's because your using a text string. So I think I also used the avionics and battery in the string as well!!! rather than visibility....
Normally visibility would not give you this issue! and it would work on a texture based gauge.

failures won't help you work this out, but i added it in the code so if there is an actual failure it will fail!

So the end fact is that you have the perfect code minus the failure. But only for text strings!

DG:eek:
 
Last edited:
I have tried && and > (for example) and some FS9 gauges don't work unless I change those to &amp;&amp; and &gt; . I don't know why...
 
failures won't help you work this out, but i added it in the code so if there is an actual failure it will fail!
Well you're right there, failure doesn't work either. I thought possibly "battery off" = "battery failure".
Failures are not something I play with much as there's very little (if any) documentation.
Thanks for ideas though.
 
Chris,
Looking at your first code example, on start (A:GPS DRIVES NAV1,Bool) would be zero so your string would be empty. The opposite state with Nav1 doing its thing might also be zero.

I have noticed where it sometimes takes two clicks to get the correct HSI readings and my solution was to code so there is a default mode perhaps called up by an enum = 0 where NAV1 is called up first.

Does not explain why the second one worked though

Roy
 
You can't write & or > directly into an XML file - it needs to be escaped using &amp; or &gt;.

Really! You mean the 34,000+ lines of XML I've used them in over the past ten years won't work?

How extraordinary... :rolleyes:

From my own experience, the only character that won't work is the less than character "<". That one most definitely must be escaped as &lt;...
 
Well, I'll defer to your greater experience, Bill, but as in XML < and > open/close tags, and the & symbol is what you use to escape characters, I was always under the impression any use of them would invalidate the XML.

Certainly when I've written these characters without escaping into ModelDef.xml or any XML gauges by accident it's always caused problems for me. Just the other day I spent an hour trying to find a problem with an animation and it turned out I hadn't escaped a > symbol.

I always use FSX XML schema unlike yourself, but I don't think that should make a difference.:confused:
 
I always use FSX XML schema unlike yourself, but I don't think that should make a difference.:confused:

Actually, I believe that does make a difference, but then that wouldn't explain modeldef.xml issues...

For example, this has never failed to work:

Code:
      <CallbackCode>
        (M:Event) 'LeftSingle'  scmi 0 == if{ (>K:ATTITUDE_BARS_POSITION_DOWN) }
        (M:Event) 'RightSingle' scmi 0 == if{ (>K:ATTITUDE_BARS_POSITION_UP) }
        (M:Event) 'WheelUp'     scmi 0 == if{ (>K:ATTITUDE_BARS_POSITION_UP) }
        (M:Event) 'WheelDown'   scmi 0 == if{ (>K:ATTITUDE_BARS_POSITION_DOWN) }
      </CallbackCode>

On the other hand, this is about the only time I use > instead of &gt;...
 
I just did some testing with my setup, and > appears to be accepted as valid in the Modeldef file, as you say, which I hadn't noticed before. Any attempt to put in < or, indeed, an & symbol resulted in a failure to load the modeldef file, and in fact temporarily caused the disappearance of my FS Tools menu!

Interesting...
 
I too found that this action symbol ">" only works with M:Events....

So I always use &gt; or &lt; when i need a range or an action.

But all my custom knobs that use M:Events needed this special action symbol...>

DG
 
Any attempt to put in < or, indeed, an & symbol resulted in a failure to load the modeldef file, and in fact temporarily caused the disappearance of my FS Tools menu!

Interesting...

It get's even more confusing when you consider that, depending on just where it is used the ampersand character (&) means two different things!

By itself, it is a bit operator:

Code:
&  bitwise AND 
op1 op2 operator  result
----------------------------
5    3      &      1
 
Back
Top