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.

Do Arithmatic in <string> {case} Evaluations?

Featured Replies

I've gotten a simple string case evaluation to work, but when I try any kind of arithmatic it just evaluates to 0:

This works:<String>Fuel Burn: %((A:NUMBER OF ENGINES, NUMBER))%{case}%{:4}%((A:Eng4 fuel flow GPH,gallons per hour))%{:1}%((A:Eng1 fuel flow GPH,gallons per hour))%{end}%!4.0d</String>This Doesn't:<String>Fuel Burn: %((A:NUMBER OF ENGINES, NUMBER))%{case}%{:4}%((A:Eng4 fuel flow GPH,gallons per hour)4*)%{:1}%((A:Eng1 fuel flow GPH,gallons per hour))%{end}%!4.0d</String>

Note the only difference is that I've tried to multiply Eng4 fuel flow by 4Any suggestions?Thank youPaul

Hi,Try:%((A:Eng4 fuel flow GPH,gallons per hour) 4 *)% May be there were some spaces missing?Jan

Jan

 

 

 

"Beatus ille qui procul negotiis..."

  • Author

That did it; thanks! Are there some rules posted in the SDK or anywhere else as to where spaces are needed in an evaluation?

  • Moderator
That did it; thanks! Are there some rules posted in the SDK or anywhere else as to where spaces are needed in an evaluation?
None that I've ever found... However, if you think about it a bit, it's really common sense to use spaces to separate words, operators, and numbers in a sentence; which is all XML script is anyway! :( Imeanhowhardisittoreadthissentencewithoutspacestoseparatethewordsfromeachother? :(

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator
None that I've ever found... However, if you think about it a bit, it's really common sense to use spaces to separate words, operators, and numbers in a sentence; which is all XML script is anyway! :( Imeanhowhardisittoreadthissentencewithoutspacestoseparatethewordsfromeachother? :(
And they say reverse polish notation (postfix, or Yoda speak) was a good thing in XML... Not to use blatant sarcasm, I think it would have been so much better if it used octal to aid in the comprehension. This said, there is a tool to convert infix to postfix in the SDK - that seems to avoid this kind of outer space (or was that spaced out?) nonsense :->Etienne
  • Author

and I thought Fortran was unforgiving! Anyway here is the completed code. Thought I'd throw it in here in case anyone struggled with spaces as long as I did. Fuel Burn and Fuel Range in nm based on number of engines:

			<Element>				<Position X="180" Y="180"/>				<FormattedText X="150" Y="16" Bright="Yes" Length="150" Font="Arial" FontSize="14" LineSpacing="16" Color="#CD8DC5">				<String>Fuel Burn: %((A:NUMBER OF ENGINES, NUMBER))%{case}				%{:4}%((A:Eng1 fuel flow GPH,gallons per hour) (A:Eng2 fuel flow GPH,gallons per hour) (A:Eng3 fuel flow GPH,gallons per hour) (A:Eng4 fuel flow GPH,gallons per hour) + + +)				%{:3}%((A:Eng1 fuel flow GPH,gallons per hour) (A:Eng2 fuel flow GPH,gallons per hour) (A:Eng3 fuel flow GPH,gallons per hour) + +)				%{:2}%((A:Eng1 fuel flow GPH,gallons per hour) (A:Eng2 fuel flow GPH,gallons per hour) +)				%{:1}%((A:Eng1 fuel flow GPH,gallons per hour))%{end}%!4.0d gph</String>				</FormattedText>			</Element>			<Element>				<Position X="180" Y="195"/>				<FormattedText X="150" Y="16" Bright="Yes" Length="150" Font="Arial" FontSize="14" LineSpacing="16" Color="#CD8DC5">				<String>Fuel Range: %((A:NUMBER OF ENGINES, NUMBER))%{case}				%{:4}%((A:Eng1 fuel flow GPH,gallons per hour) (A:Eng2 fuel flow GPH,gallons per hour) (A:Eng3 fuel flow GPH,gallons per hour) (A:Eng4 fuel flow GPH,gallons per hour) + + + 60 / (A:FUEL TOTAL QUANTITY, gallon) r / 60 / (A:GPS Ground Speed, knot) *)				%{:3}%((A:Eng1 fuel flow GPH,gallons per hour) (A:Eng2 fuel flow GPH,gallons per hour) (A:Eng3 fuel flow GPH,gallons per hour) + + 60 / (A:FUEL TOTAL QUANTITY, gallon) r / 60 / (A:GPS Ground Speed, knot) *)				%{:2}%((A:Eng1 fuel flow GPH,gallons per hour) (A:Eng2 fuel flow GPH,gallons per hour) + 60 / (A:FUEL TOTAL QUANTITY, gallon) r / 60 / (A:GPS Ground Speed, knot) *)					%{:1}%((A:Eng1 fuel flow GPH,gallons per hour) 60 / (A:FUEL TOTAL QUANTITY, gallon) r / 60 / (A:GPS Ground Speed, knot) *)%{end}%!03d! nm</String>				</FormattedText>			</Element>

No doubt there is a more elegant way to do this, nevertheless, it works. Thanks for the help, guys.

And they say reverse polish notation (postfix, or Yoda speak) was a good thing in XML... Not to use blatant sarcasm, I think it would have been so much better if it used octal to aid in the comprehension. This said, there is a tool to convert infix to postfix in the SDK - that seems to avoid this kind of outer space (or was that spaced out?) nonsense :->Etienne
Actually FS XML team didn't make the choice for rpn just to complicate gauge programmers, but because it's a very efficient way to handle a scriptying system like the one used in XML code. Most of complex arithmetic and logical operations can be managed with a bunch of very simple low level functions that use rpn method, something that wouldn't be possible with the standard infix notation.Tom

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.