March 4, 200917 yr 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
March 4, 200917 yr 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..."
March 4, 200917 yr 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?
March 4, 200917 yr 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
March 4, 200917 yr 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
March 5, 200917 yr 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.
March 5, 200917 yr 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 :->EtienneActually 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