May 2, 201214 yr Hi, FSX is complaining about this snippet of XML, but I don't understand why. Could someone please help me figure out what, if anything, is wrong with this XML fragment? Color="%((G:Var1) 0 == if{ 'White' } els{ '#a0a0a0' })%!s!" The error message displayed by FSX is Error: Invalid script (no command is more than 4 characters): ")%!s!" Thanks for any help. Eric
May 2, 201214 yr fs9 don't know that synthax, if it is for changing text color try something like: Color="%('White' '#a0a0a0' (G:Var1) 0 == ?)" or Color="%('White' '#a0a0a0' (G:Var1) 0 != ?)" Hope it helps, Jan "Beatus ille qui procul negotiis..."
May 2, 201214 yr Author Hi Jan, Thank you. I will try that when I get a chance. The odd thing is, the gauge seems to work fine in FSX even though the simulator displays that error message! I find that to be confusing. Eric
May 2, 201214 yr Moderator The syntax rules for scripted text are different from what you're accustomed to. Instead of if{ xxx } and els{ xxx }use instead %{if} and %{else}... ...also, you can't change the Color value that way. Here is an example that changes the display color from Lime to White depending on whether COM1 TRANSMIT is selected or deselected: <Element> <Position X="684" Y="42"/> <Visible>(A:AVIONICS MASTER SWITCH,bool)</Visible> <FormattedText X="60" Y="35" Font="Glass Gauge" FontSize="20" LineSpacing="0" Adjust="CENTER" Color="Lime" Bright="Yes"> <Color Value="White"/> <String>%((A:COM1 TRANSMIT,bool) 1 ==)%{if}%((A:COM1 ACTIVE FREQUENCY,Mhz))%!2.2f!%{else}%\{clr2}%((A:COM1 ACTIVE FREQUENCY,Mhz))%!2.2f!%</String> </FormattedText> </Element> Note that the "primary" Color is declared in the <FormattedText.../> parameter list. The "alternate" Color is declared in the <Color Value=.../> entry. Switching the Color is accomplished by the %\{clr2} escape code. The escape code %\{clr} will reselect the Primary Color. In yet another example of the inconsistency of ACES, note that the index numbering for Color is different from that used by Font! For example: %\{fnt} = Primary Font %\{fnt1} = 1st Alternate Font %\{clr} = Primary Color %\{clr2} = 1st Alternate Color Fr. Bill AOPA Member: 07141481 AARP Member: 3209010556 Avsim Board of Directors | Avsim Forums Moderator
May 2, 201214 yr That is ok too and i use it for big text elements like eisas etc. But this works also: <Element> <Position X="52" Y="14"/> <FormattedText X="45" Y="18" Bright="Yes" Font="Arial" FontSize="18" Color="%('dkgray' 'orange' 'red' (A:General eng1 exhaust gas temperature,celsius) sp1 l1 675 >= ! ? l1 650 < l1 675 >= ! and ?)" Adjust="Center" VerticalAdjust="center"> <String>\{bo}%((A:ENG1 EXHAUST GAS TEMPERATURE,celsius))%!3d!</String> </FormattedText> </Element> Jan "Beatus ille qui procul negotiis..."
May 3, 201214 yr Author Hi Bill, Thanks very much. This gauge needs to work in both FS9 and FSX. I'm a newbie to XML programming. Will the code you posted work in both sims? When you said The syntax rules for scripted text are different from what you're accustomed to. I had to laugh a bit because I don't even know what "scripted text" is. Does that refer to trying to code an if-then-else construct inside double quotes? Eric
May 3, 201214 yr Moderator Hi Bill, Thanks very much. This gauge needs to work in both FS9 and FSX. I'm a newbie to XML programming. Will the code you posted work in both sims? When you said I had to laugh a bit because I don't even know what "scripted text" is. Does that refer to trying to code an if-then-else construct inside double quotes? Yes, I only work with FS9 XML syntax/schema, since I need it to work in both FS9 and FSX. By "scripted text" I mean any form of <Text> or <FormattedText> display script. That is ok too and i use it for big text elements like eisas etc. But this works also: Color="%('dkgray' 'orange' 'red' (A:General eng1 exhaust gas temperature,celsius) sp1 l1 675 >= ! ? l1 650 < l1 675 >= ! and ?)" Oh, quite right. I forgot about that version of a "enumerated case" construct, probably because I've never had a use for it. Fr. Bill AOPA Member: 07141481 AARP Member: 3209010556 Avsim Board of Directors | Avsim Forums Moderator
May 4, 201214 yr Author Hi Bill, I finally had time to try out switching from text to formatted text. The good news is ... the color switching works perfectly! Thank you. The bad news is ... now the text is about 1/10th the size it used to be and is now impossible to read. So, this code, though it generated an FSX error message, actually worked (i.e. the colors switched and the text was the right size): <Text X="172" Y="24" Bright="Yes" Length="13" Font="Glass Gauge" Color="%((G:Var1) 0 == if{ 'White' } els{ '#a0a0a0' })%!s!" Adjust="Center" VerticalAdjust="Bottom" Fixed="Yes" Multiline="No"> <String>Course</String> </Text> while this code also switches colors correctly but produces text that is too small to read: <FormattedText X="172" Y="24" Bright="Yes" Length="13" Font="Glass Gauge" Color="White" Adjust="Center" VerticalAdjust="Bottom" Fixed="Yes" Multiline="No"> <Color Value="#a0a0a0"/> <String>%((G:Var1) 0 ==)%{if}Course%{else}\{clr2}Course%{end}</String> </FormattedText> I have tried searching through the main FSX SDK help file for "formattedtext" but it claims there is no such thing :Phbbbt: . I am obviously missing something, but I don't know what. Do you know what is causing the text to be resized? Thanks for your patience. You have certainly earned the "tutor" badge. Eric
May 4, 201214 yr You need to add FontSize="24" x/y in form.text defines only the format of the total text block. you can also erase multiline= and fixed= Hope it helps, Jan "Beatus ille qui procul negotiis..."
May 4, 201214 yr Moderator I have tried searching through the main FSX SDK help file for "formattedtext" but it claims there is no such thing :Phbbbt: . I am obviously missing something, but I don't know what. Do you know what is causing the text to be resized? Thanks for your patience. You have certainly earned the "tutor" badge. Jan gave you the solution, so let's compare the differences between simple <Text> versus <FormattedText>. <Text> <Text X="172" Y="24" Length="13" In the example above, we are defining a "text box" 172 units wide by 24 units high, with a maximum of 13 characters. FS will attempt to resize the text automatically to "fill the box" depending on gauge size, screen size and resolution. In other words, it's not really very dependable or predictable. <FormattedText> <FormattedText X="172" Y="24" FontSize="24" In the example above, we are defining the same size of "text box," but are declaring a font size of 24 points. Since both "units" and "points" are relative values, when FS renders the text it will always be the same precise ratio regardless of the "gauge size", the "screen size" or the "resolution". Now we have consistency and predictability! (mostly, there are some occasional exceptions of course). I've found through my own experience that it's frequently helpful to make the height of the text box 2 units more than the font size specified, so in the above I'd either have FontSize="22" or Y="26"... Fr. Bill AOPA Member: 07141481 AARP Member: 3209010556 Avsim Board of Directors | Avsim Forums Moderator
May 5, 201214 yr Author Gentelmen, thank you very much. FontSize did the trick. Do either of you know if FormattedText is documented anywhere? As I said, I looked in the FSX SDK but searching the help file turned up nothing. Eric
May 5, 201214 yr Hi, Very useful: http://blogs.technet.com/b/engauged/archive/2005/11/08/413948.aspx You can look here and download a small example i made long ago. http://www.fs2x.com/Tutorials.htm This is the gauge: http://www.fs2x.com/...xampleGuage.zip Not extensive, but it will give an impression of what you can do. Jan "Beatus ille qui procul negotiis..."
May 5, 201214 yr Author Hi Jan, You are right - very useful. Thanks for your example gauge also. Eric
May 5, 201214 yr Moderator Gentelmen, thank you very much. FontSize did the trick. Do either of you know if FormattedText is documented anywhere? As I said, I looked in the FSX SDK but searching the help file turned up nothing. Unfortunately, there is nothing specific to <FormattedText> that I've ever found. I had to learn it the "hard way" via deciphering the examples in the fs9gps.cab file and job lots of "Trial-and-Error," with major emphasis on the "Error" part... :LMAO: Fr. Bill AOPA Member: 07141481 AARP Member: 3209010556 Avsim Board of Directors | Avsim Forums Moderator
Create an account or sign in to comment