Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[FS2004] Expressions in value tag not being computed

Featured Replies

Hey guys,I am trying to design an XML fuel gauge for the C172 aircraft, which has a status bitmap at the bottom of the fuel gauge which will either display Fuel Insufficient if the time to fuel exhaustion is less than the time to the next GPS waypoint, or Fuel Ok if there is sufficient fuel onboard. I have used a Select tag at the bottom which toggles the corresponding bitmap to display depending on the value computed like such -

<Element>	<Position X="72" Y="305"/>	<Visible>(A:GPS IS ACTIVE FLIGHT PLAN, bool)</Visible>	<Select>	<Value>((A:fuel total quantity, gallons) (A:eng1 fuel flow GPH, gallons per hour) /) ((A:GPS WP DISTANCE, kilometer) (A:GPS GROUND SPEED, kilometer per hour) /) > if{ 1 } els{ 0 }</Value>	<Case Value="0">		<Image Name="FuelInsufficient.bmp" Luminous="Yes"/>	</Case>	<Case Value="1">		<Image Name="FuelOk.bmp" Luminous="Yes"/>	</Case>	</Select></Element>

However, I realised that the two expressions in the Value tag in the middle are not evaluating (they evaluate to 0), and hence, the entire expression always evaluates to the else clause.The expressions should be correctly defined as they are used further up in the XML file where they are evaluated within a String tag.Would very much appreciate any help that anyone could provide on this issue. Thanks to all in advance!

  • Moderator

Syntax for <Value> is different than the syntax used in <String> expressions. Try this instead:

<Value>  (A:fuel total quantity, gallons)  (A:eng1 fuel flow GPH, gallons per hour) /  (A:GPS WP DISTANCE, kilometer)  (A:GPS GROUND SPEED, kilometer per hour) /  >  if{ 1 } els{ 0 }</Value>

Of course, the real question is why you are calculating this twice (or more?). Why not encapsulate the calculation in a <Macro>, place it in an <Update> section and then use the @Macro to get the returned value for both the <String> and this <Element> section?

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator
  • Commercial Member

I tested your expression in isolation and it evaluated to 1 when the conditions agreed.However I did remove the parentheses and used > instead of >Something to try anyway...Danny

<Value>(A:fuel total quantity, gallons) (A:eng1 fuel flow GPH, gallons per hour) / (A:GPS WP DISTANCE, kilometer) (A:GPS GROUND SPEED, kilometer per hour) / >if{ 1 }els{ 0 }</Value>

Edit

...Of course, the real question is why you are calculating this twice (or more?). Why not encapsulate the calculation in a <Macro>, place it in an <Update> section and then use the @Macro to get the returned value for both the <String> and this <Element> section?
Hi Bill,You're absolutely spot on... we should calculate this once and reuse it and that's what I've tried to do.In the element which displays this as a string I have done something similar to -
   <Element>    <Position X="72" Y="308"/>    <Value>((A:fuel total quantity, gallons)  (A:eng1 fuel flow GPH, gallons per hour) /) (>L:myTTE,hour)</Value>    <Text ...>        <String>%(L:myTTE,hour)%!2.2f!</String>    </Text></Element>

However, the string bit always evaluates to 0 (i.e. my local variable). Do I need to encapsulate it in an Update tag in order for it to periodically refresh?

  • Moderator
However, the string bit always evaluates to 0 (i.e. my local variable). Do I need to encapsulate it in an Update tag in order for it to periodically refresh?
Get rid of the parenthesis. Those are only allowed in <String> expressions. Also the unit "hour" is not valid, use "number" instead:
<Value>(A:fuel total quantity, gallons) (A:eng1 fuel flow GPH, gallons per hour) / (>L:myTTE,number)</Value>

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator
  • Commercial Member
Get rid of the parenthesis. Those are only allowed in <String> expressions. Also the unit "hour" is not valid, use "number" instead:
<String>%[b]([/b](L:myTTE,hour)[b])[/b]%!2.2f!</String>

<Value>(A:fuel total quantity, gallons) (A:eng1 fuel flow GPH, gallons per hour) / (A:GPS WP DISTANCE, kilometer) (A:GPS GROUND SPEED, kilometer per hour) / >if{ 1 }els{ 0 }</Value>if{ 1 } els{ 0 } is redundant. It'll work, but it's completely unnecessary as the stack in your expression will evaluate to either 0 or 1 anyway. There is no need to ever use if{ 1 } els{ 0 } together in any XML code for any reason. It just adds extra overhead.If you were to put that expression in a string directly:

<String>%((A:fuel total quantity, gallons) (A:eng1 fuel flow GPH, gallons per hour) / (A:GPS WP DISTANCE, kilometer) (A:GPS GROUND SPEED, kilometer per hour) / >)%!5.2f!</String>

It would print as 0 or 1 without any additional code.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.