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

String loop causing index misnumbering

Messages
129
Country
us-indiana
Hello. Attached is a couple of examples. The first method (shown in mostly blue) shows the information correctly but is too verbose/repetitive. The second method (shown in pink) is efficient but the displaying of the FlightPlanWaypointIndex is off on the first waypoint. How the 47 is determined has me confused.

Method 1 xml:
Code:
<Element>
<Position X="49" Y="58"/>
      <Text X="150" Y="18" Length="40" Font="consolas" FontSize="10" Fix="Yes"
Color="%((A:GPS FLIGHT PLAN WP INDEX, number) 1 == if{ '#FF0088' } els{ '#0088FF'})%!s!" Adjust="Left" VerticalAdjust="Center">
         <String>% 1.%(1 (&gt;
C:fs9gps:FlightPlanWaypointIndex))%((C:fs9gps:FlightPlanWaypointIdent, string))%!s!
</String>    </Text>
</Element>

<Element>
<Visible>(A:GPS FLIGHT PLAN WP COUNT, number) 2 &gt; </Visible>
<Position X="49" Y="68"/>
      <Text X="150" Y="18" Length="30" Font="consolas" FontSize="10" Fix="Yes"
Color="%((A:GPS FLIGHT PLAN WP INDEX, number) 2 == if{ '#FF0088' } els{ '#0088FF'})%!s!" Adjust="Left" VerticalAdjust="Center">
         <String>% 2.%(2 (&gt;
C:fs9gps:FlightPlanWaypointIndex))%((C:fs9gps:FlightPlanWaypointIdent,string))%!s!
</String></Text>
</Element>

etc. for a maximum of 48 waypoints.

Method 2:

Code:
<Element>
   <Position X="84" Y="58" />
   <FormattedText X="255" Y="295" Font="Consolas" FontSize="11" LineSpacing="10.2"

Color="%((A:GPS FLIGHT PLAN WP INDEX, number) 1 == if{ '#FF0088' } els{ '#0088FF'})%!s!" Bright="Yes" Adjust="Left" Fix="Yes">
            <String>
%((@c:FlightPlanWaypointsNumber) s2 0 !=)
%{if}
%(1 sp1)
%{loop}
%((C:fs9gps:FlightPlanWaypointIndex) 1 +)%!2d!%.%(l1 (&gt;
C:fs9gps:FlightPlanWaypointIndex))%((C:fs9gps:FlightPlanWaypointIdent, string))%!s!%
\n %(l1 ++ s1 l2 15 - &lt;)
%{next}
%{end}
</String>   </FormattedText>
</Element>

<Element>
   <Position X="195" Y="47" />
   <FormattedText X="255" Y="295" Font="Consolas" FontSize="11" LineSpacing="10.2"
Color="%((A:GPS FLIGHT PLAN WP INDEX, number) 1 == if{ '#FF0088' } els{ '#0088FF'})%!s!" Bright="Yes" Adjust="Left" Fix="Yes">
            <String>
%((@c:FlightPlanWaypointsNumber) s2 0 !=)
%{if}
%(22 sp1)
%{loop}
%((C:fs9gps:FlightPlanWaypointIndex) 1 +)%!2d!%.%(l1 (&gt;
C:fs9gps:FlightPlanWaypointIndex))%((C:fs9gps:FlightPlanWaypointIdent, string))%!s!%
\n %(l1 ++ s1 l2 &lt;)
%{next}
%{end}
</String>   </FormattedText>
</Element>

As far as I can tell, unlimited number of waypoints but I don't know how to use tab so I set it up to repeat every 22 waypoints. I've never seen more than 40 (a flightplan KSAN to KJFK) once.
Does anyone have an idea how the code determines why the first waypoint (method 1) shows as no. 47? There are 37 (C:fs9gps:FlightPlanWaypointsNumber) waypoints in this particular flight plan. Thank you.
 

Attachments

  • IndexNumberIssueUsingStringLoop.PNG
    IndexNumberIssueUsingStringLoop.PNG
    76.5 KB · Views: 206
As far as I know there is not a limit on the number of waypoints that one can use .
In my case it is limited to 100 because I only make a provision for 2 characters for the Flight plan INDEX number , resulting in
00 plus 99 = 100 .
If I allowed 3 characters I would have 000 plus 999 = 1000 waypoints .

You may be getting 47 because the sim count starts at 00 , therefore 00 plus 47 = 48 .

An example of a flight plan with a large number of waypoints is the Grand Canyon plan at
Simviation , under FS Navigation , page 30 ,

FS2004 Flight through the Grand Canyon
Zip file preview
1.86Mb (414 downloads)
FS2004 Flight Plan for a flight through the Grand Canyon. If you want some spectacular views and fun flying try out this flight plan. There are over 800 waypoints used that take you through most of the canyon. Two flights included. One going eastbound and the other going westbound. You will be flying in the default Cessna 172 with the autopilot connected. Just sit back and watch the scenery go by. Don't get too relaxed because there are a couple of turns that you will have to take control of the aircraft. Included in this package is a gauges by Karol Chlebowski for TFR flying which enhance the sight seeing experience. Another option to download Version 2.0 of FS2004 my mini panel which has all this functionality included and more.
Posted Jul 16, 2011 11:24 by Bill McClellan

Cheers
Karol
 
Here is your Method 2, bottom-most Element:

1600706155690.png


The first time through the loop, FlightPlanWaypointIndex is not associated with the value in Register 1 (line 10). FlightPlanWaypointIndex was apparently 46 when the loop started.

You might consider something like this instead:

1600706003430.png


Adjust the initial value of Register 1 (line 8) or delete the "1 +" in line 11, as appropriate.

No need for the %!s! in the Color tag.

Bob
 
Hello. Thank you for your responses. To COBS, you wrote: You may be getting 47 because the sim count starts at 00 , therefore 00 plus 47 = 48. The 48 was the limit I set for Method 1. I still don't understand where the 47 comes in as the maximum number of waypoints was 37, so 37 + 1 = 38. I didn't use a limit for Method 2. I was using both methods so perhaps I need to remove Method 1. I tried that but that made no changes, other than legs not showing in blue. To rpmc, I attempted to copy your code from above (thank you) but was difficult to make an exact copy as your "code" was a png instead of inserted as \code. I initially mistyped so it took a few re-types. I did use %(1 sp1) instead of 22 as I wanted to start at the first waypoint. Your method worked - thank you. The only thing is, however, the "next waypoint" wasn't in a different color as can be seen in Method 1 (which is mostly blue, except for the next waypoint). Is there a way to use tab so that I can start a new column, say when the 1st column is larger than 22 waypoints (I did try but to no avail)?
 
Last edited:
If "next waypoint" means FlightPlanActiveWaypoint, then try:

XML:
<Element>
  <Position X="196" Y="47" />
  <FormattedText X="255" Y="295" Font="Consolas" FontSize="11" LineSpacing="10.2" Color="blue" Bright="Yes" Adjust="Left" Fix="Yes">
        <Color Value="magenta"/>
        <String>
            %((C:fs9gps:FlightPlanWaypointsNumber) s2 0 !=)
                %{if}
                    %(0 sp1)
                    %{loop}
                      %(l1 (C:fs9gps:FlightPlanActiveWaypoint) ==)%{if}%\{clr2}%{end}
                      %(l1 (>C:fs9gps:FlightPlanWaypointIndex))
                      %((C:fs9gps:FlightPlanWaypointIndex))%!2d!
                      %.
                      %((C:fs9gps:FlightPlanWaypointIdent, string))%!s!%\n\{clr}
                      %(l1 ++ s1 l2 &lt;)
                    %{next}
                %{end}
        </String>   
    </FormattedText>
</Element>


To get the flight plan to show in two columns, a good way to go is as you set it up above - two separate Elements. I'd use Register 2 for the second Element. Adjust the start/stop numbers of the loop for each Element according to the max number of waypoints you allow for each column. You might also want to reduce the FormattedText X="x" values so that the display widths do not overlap.
 
Hello rpmc. Thank you for your response. That works and thanks for putting the info in a code. One final question, to me, it's a condition (continue to increments as long as l1 is less than l2):
%(l1 ++ s1 l2 &lt;) ... so why isn't an {if} required here?
 
Back
Top