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

FSX Conditional statement in formatted text

Messages
542
Country
australia
I have the following formatted text in an instrument.
HTML:
	<!--Target-->
				<Element id="Target_Data">
					<FloatPosition>0.000,30.000</FloatPosition>
					<Visibility>(L:TGTscript, number) 1 ==</Visibility>
					<GaugeText id="target">
						<BackgroundColorScript>0x000000</BackgroundColorScript>
						<FontColorScript>0xFFFFAA</FontColorScript>
						<FontHeight>16</FontHeight>
						<Tabs>0L,5L,275L</Tabs>
						<GaugeString>\t%Brg %(@ClosingSpeed (&gt;L:ClosingSpeed,number))%(@AspectAngle (&gt;L:AspectAngle,number))
								%((L:Target_Bearing, number))%!4d!\{dplo= }  			
								\t\t%Cls %((L:ClosingSpeed,number))%!4d!
								\n\n\t%Gs %((L:Target_Groundspeed, number) 10 / near 10 *)%!4d!%kt%
								\t\t%Alt %((L:Target_Altitude, number) 100 / near)%!4d!\{dpl=FL}
								\n\n\t%Hdg%((L:Target_Heading, number))%!4d!%\{dplo= }
								\t\t%Dst %((L:Target_Distance, number))%!4.1f!\{dpl=nm}
								\n\n\t%VSI: %((L:Target_VSI, feet per minute))%!d!
						%</GaugeString>
						<Length>350</Length>     
						<Size>350,160</Size>
						<Bright>True</Bright>
					</GaugeText>
				</Element>

This portion gives the distance between the user aircraft and the selected AI target aircraft in NM.
HTML:
\t\t%Dst %((L:Target_Distance, number))%!4.1f!\{dpl=nm}

What I now want is this line to read as follows:
if distance is greater than 1.6NM then readout in NM.
else distance is less than 1.6 NM then readout in ft.

I tried the following , but it does not work .
HTML:
%((L:Target_Distance, number) 1.6 &gt;)%{if}%((L:Target_Distance, number))%!4d!\{dpl=nm}%{els}%((L:Target_Distance, number) 6076 *)%!4d!%

Any ideas on getting this conditional statement to work in formatted text ?

Cheers
Karol
 

taguilo

Resource contributor
Messages
1,585
Country
argentina
Karol,

Conditional syntax in <FormattedText> scripts is different to what is used on the rest of the scripts:

{if} {else} {end}

Notice the extra e in the {else}. Also I suspect {end} isn't really necessary if there is no additional text/value to display after the {else} text/value.

Tom
 
Messages
542
Country
australia
Tom

Thank you .
This now works nicely.

HTML:
%Dst %((L:Target_Distance, number) 1.59 &lt;)%{if}%((L:Target_Distance, number) 6076 *)%!4d!%ft%((L:Target_Distance, number) 1.6 &gt;)%{else}%((L:Target_Distance, number))%!4.1f!\{dpl=nm}%{end}%

Cheers
Karol
 
Messages
542
Country
australia
Previously if I was in close on an intercept or doing formation flying the nautical mile distance readout was useless , having it in feet is superb .
In this case 223 ft to the AI at the left.
The ' 223 ft ' field reads in nm until about 9,000 ft from the AI , closer than that it reads in feet.
While I was at it I added the AI VSI which tells you what the AI is up to.

On the radar screen the "AA" button makes the screen clickable to enable selection of a specific AI , and adds the text overlay and the blue pointer arrow,at the same time it feeds the AI data to the text block at the top of the HUD .
It all makes formation flying easier and more enjoyable .

Cheers
Karol

oW9GX.jpg
 
Last edited:
Messages
542
Country
australia
Just for information.

In both the HUD and Radar in the shot there is a value " Brg -13 degree " ,
it is a bearing relative to the nose of your aircraft indicating direction to AI.
- 13 is to the left
+ 13 is to the right

It was annoying as it relies on remembering direction of - or + .

In the first 2 lines of code in post #2 at the following link is solution.
http://www.fsdeveloper.com/forum/showthread.php?t=286781

I changed this line that was in above formatted text ,
FROM
HTML:
%((L:Target_Bearing, number))%!4d!\{dplo= }

TO
HTML:
%((L:Target_Bearing, number) abs flr )%!3d!\{dplo= }%  %((L:Target_Bearing, number) 0 &lt; if{ 'L' } els{ 'R' } )%!s!

The display now ends in 'L' or 'R' depending on which side the AI is.
Much better as Left and right make sense , whereas - or + only make sense if a pre condition is known or remembered.

Cheers
Karol
 
Last edited:
Top