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

Decimal degrees conversion random error

Hi,

I come back; It was 1:30 Am in France.

Tgibson was not far from the solution.


As you probably noticed, when you want to use the symbol ° in FSX, this often causes an error or crash.

So I ask myself how FSX do write his .PLN file , which contain this character °.

So I opened a FSX .PLN file with an hexadecimal editor, because I suspected there had a ingeniousness : And I saw that it had the character 194 (C2 in hexa ) in front of each °, but it does not appear in a text editor.

So, with this character 194 in front of each °, no more worries.

I already stated this tip at the end of this post, few months ago : http://www.fsdeveloper.com/forum/showthread.php?t=359489

I saw also with the hexadecimal editor that the xml file had a invisible header composed of three special characters: 239, 187 and 191. I guess it must be the header recognition of an xml file, so since I add these 3 characters at the beginning of all my XML files.


To me th have a question :

Now that my problem is solved, if you have see my Save_FP.xml file, you have seen that I use 2 x 3 times this same portion of conversion code from decimal degrees to degrees, minutes, seconds


I use it for the departure position (LAT and LONG)
For the destination postion (LAT and LONG )

and in the loop to write all the waypoints of the flight plan.


Do you think that is possible to transform this portion of code in a Macro ?

My new code that works is (example with a waypoint latitude) :
Code:
(* Waypoint position latitude *)
(* latitude Hundredth of Seconds*)
(C:fs9gps:FlightPlanWaypointLatitude,degrees) abs 1 % 60 * 1 % 60 * 1 % 100 * near (>L:Hundredth_Seconds,number)
'Hundredth_Seconds_String' (>C:XMLVARS:SearchVarName,string)
(L:Hundredth_Seconds,number) 10 < if{ '0' (L:Hundredth_Seconds,number) scat (>C:XMLVARS:StringValue,string) } els{ (L:Hundredth_Seconds,number) (>C:XMLVARS:StringValue,string) }    
(* latitude Seconds*)
(C:fs9gps:FlightPlanWaypointLatitude,degrees) abs 1 % 60 * 1 % 60 * near (>L:Seconds,number)
(C:fs9gps:FlightPlanWaypointLatitude,degrees) abs 1 % 60 * flr (>L:Minutes,number)
(C:fs9gps:FlightPlanWaypointLatitude,degrees) abs flr (>L:Degrees,number)
(L:Seconds,number) 60 == if{ (L:Minutes,number) 1 + (>L:Minutes,number) 0.00 (>L:Seconds,number) }
(L:Minutes,number) 60 == if{ (L:Degrees,number) 1 + (>L:Degrees,number) 0 (>L:Minutes,number) } 
(* Latitude degrees *)
'VarTemp' (>C:XMLVARS:SearchVarName,string)
(L:Degrees,number) flr (>C:XMLVARS:StringValue,string)
(C:fs9gps:FlightPlanWaypointLatitude,degrees) 0 < if{ 'S' (C:XMLVARS:StringValue,string) scat (>C:XMLVARS:StringValue,string) } els{ 'N' (C:XMLVARS:StringValue,string) scat (>C:XMLVARS:StringValue,string) }
'VarWaypointLatitude' (>C:XMLVARS:SearchVarName,string) (C:XMLVARS:StringValue,string) 'VarTemp' (>C:XMLVARS:SearchVarName,string) (C:XMLVARS:StringValue,string) scat 194 chr scat '° ' scat 'VarWaypointLatitude' (>C:XMLVARS:SearchVarName,string) (>C:XMLVARS:StringValue,string)
(* Latitude minutes *)
'VarTemp' (>C:XMLVARS:SearchVarName,string) 
(L:Minutes,number) flr (>C:XMLVARS:StringValue,string)
'VarWaypointLatitude' (>C:XMLVARS:SearchVarName,string) (C:XMLVARS:StringValue,string) 'VarTemp' (>C:XMLVARS:SearchVarName,string) (C:XMLVARS:StringValue,string) scat ''' ' scat 'VarWaypointLatitude' (>C:XMLVARS:SearchVarName,string) (>C:XMLVARS:StringValue,string)
(* Latitude seconde et centieme de seconde *)
'Hundredth_Seconds_String' (>C:XMLVARS:SearchVarName,string) 
(L:Seconds,number) (C:XMLVARS:StringValue,string) scat 'VarTemp' (>C:XMLVARS:SearchVarName,string) (>C:XMLVARS:StringValue,string)
(C:XMLVARS:StringValue,string) slen (>G:Var9) (C:XMLVARS:StringValue,string) 0 (G:Var9) 1 - ssub (>C:XMLVARS:StringValue,string)
'VarWaypointLatitude' (>C:XMLVARS:SearchVarName,string) (C:XMLVARS:StringValue,string) 'VarTemp' (>C:XMLVARS:SearchVarName,string) (C:XMLVARS:StringValue,string) scat '"' scat 'VarWaypointLatitude' (>C:XMLVARS:SearchVarName,string) (>C:XMLVARS:StringValue,string)

And I use the same code with :
- (C:fs9gps:FlightPlanDepartureLatitude,degrees
- (C:fs9gps:FlightPlanDepartureLongitude,degrees)
- (C:fs9gps:FlightPlanDestinationLatitude,degrees)
- (C:fs9gps:FlightPlanDestinationLongitude,degrees)

and in the loop with :
- (C:fs9gps:FlightPlanWaypointLatitude,degrees)
- (C:fs9gps:FlightPlanWaypointLongitude,degrees)




Is there a advantage to do transform in Macro that if it is possible ? (code of this gauge is only executed when the user save this mofied flight plan, so the file is not executed all the time)

I think that it is not essential in this case . What do you think about this ?

And if yes, how do because, I don't understand the reading of the macro.

How write the macro, how send the command and the value, and how get the return value.
 
Last edited:
So, with this character 194 in front of each °, no more worries.

I already stated this tip at the end of this post, few months ago : http://www.fsdeveloper.com/forum/showthread.php?t=359489

I saw also with the hexadecimal editor that the xml file had a invisible header composed of three special characters: 239, 187 and 191. I guess it must be the header recognition of an xml file, so since I add these 3 characters at the beginning of all my XML files.

Francois,

Thanks for this tip! Sorry I forgot about your earlier post. And your method to open the pln file with a hexadecimal editor is a very good process tip for everyone to remember. Good job.

Do you think that is possible to transform this portion of code in a Macro ?
Is there a advantage to do transform in Macro that if it is possible ? (code of this gauge is only executed when the user save this mofied flight plan, so the file is not executed all the time)

I think that it is not essential in this case . What do you think about this ?

And if yes, how do because, I don't understand the reading of the macro.

How write the macro, how send the command and the value, and how get the return value.

Concerning the macro, you certainly could make that sequence into a macro, being careful to make it generic for use with either latitude or longitude and to handle the XMLVARS the way you want.

Macros are straightforward. As you may know, they are simply literal replacements of text that make your gauge code easier to read and edit. That's the advantage of using macros - less lines of code to keep up with when you are writing/editing your gauge.

The programming experts in this forum can correct the following statement, but I believe that when your gauge is loaded by FS, the macros are all "inserted" back into the code body. I know my terminology here is incorrect, but the point is that I don't think there is any performance advantage to using macros, only an appearance advantage to the programmer.

You have already made a performance optimization if you prevent the macro section from running except when triggered by a save flight plan command.

If it is difficult to make this into a generic macro that works with both lat and lon, then keep it simple and go with the code that works.

Anyway, before long Bill Leaming or Tom Aguilo might jump in here and show us how to properly write the macro for that.

Bob
 
Last edited:
While you could make your script easier to read by creating and using @Macros, you risk breaking something during the process...

...as a consequence, I advise against it since what you have is working! :D

But, just for the sake of providing the information, here is an example:


Code:
<Macro Name="FPWP_lat">(C:fs9gps:FlightPlanWaypointLatitude,degrees) abs</Macro>

To use this, simply replace every instance of the above with @FPWP_lat...

Code:
@FPWP_lat 1 % 60 * 1 % 60 * 1 % 100 * near (>L:Hundredth_Seconds,number)
 
Francois,

The programming experts in this forum can correct the following statement, but I believe that when your gauge is loaded by FS, the macros are all "inserted" back into the code body. I know my terminology here is incorrect, but the point is that I don't think there is any performance advantage to using macros, only an appearance advantage to the programmer.

What Bob states here is absolutely true.

While you could make your script easier to read by creating and using @Macros, you risk breaking something during the process...
...as a consequence, I advise against it since what you have is working! :D

I fully agree with Bill as well.

My advise on this issue, and speaking of a way to improve XMLVars' coding would be: read the documentation included, find the macros I've added and when you have some time just test them :) And don't hesitate to ask about anything you don't understand, somebody here will help you for sure.

Tom
 
I fully agree with Bill as well.

Tom, that was speaking from bitter experience. Not all that long ago (a few weeks at most) I managed to FUBAR a rather complex bit of logic by trying to make my script more "readable"...

...without having the good sense to make a backup copy of the working script first...

You can imagine the frustration and self-recriminations that followed that particular bout of stupidity!

As a general rule-of-thumb though, I don't bother with an @macro unless I know ahead of time I'm going to be using what it represents more than a half-dozen times in any given gauge script.

For example, I have ten "warning lights" on the glareshield of my current project, each of which will be referenced many, many times in the final section of controlling logic. It only makes good sense then to have them "macroized..." :D

Code:
  <!-- WARNING LIGHTS -->
  <Macro Name="ElecWarnOn">(>L:B737_ElecWarn_Light, enum)</Macro>
 
Thank you very much for your precious advice !

I promise you that I will make an effort to use more macros.

I have a last question :

Today,my gauge save its modified flight plan by using Logger , in a specific folder that I have created .

But, I would like save these flight plans in the same folder of FSX "My documents\....."

Is there a way to get this windows environment path in xml, regardless of the location or installed FSX and the place where Flight Simulator is ?

Because, I prefer that all the flight plan are in the same folder, and I would like I would avoid the user to create a folder or enter the full path.

Thank you

Francois
 
But, I would like save these flight plans in the same folder of FSX "My documents\....."

Is there a way to get this windows environment path in xml, regardless of the location or installed FSX and the place where Flight Simulator is ?

Because, I prefer that all the flight plan are in the same folder, and I would like I would avoid the user to create a folder or enter the full path.

Francois,

If you are asking is there an automatic way for your XML gauge to know what path LOGGER should use to write the file, I'm not sure .... never thought about that before. Certainly, there is no XML variable that can be of use as FS never contemplated XML > HDD > XML file manipulation in the first place.

However, you could try putting the LOGGER module in the same folder as the .pln files and then editing the <Path> statement in the dll.xml file accordingly. I admit that I am not sure if a module can be placed outside of the root FS directory or exactly how to edit <Path> in this circumstance, but it is worth a try. When using LOGGER, you would omit the full path and specify filename.ext only as per instructions in the LOGGER help file. I believe LOGGER will store the files it writes to that folder when the path is omitted, but experiment to see what happens. I never tried.

Having said that, it seems to me that it's just as easy for your users to edit a very simple one line macro in your XML gauge to specify the flight plan file path as it is to ask them to install LOGGER in the flight plan folder and edit dll.xml.

Bob
 
Last edited:
Hi bob,

Excuse me for my late reply, but I was very busy since 2 days.

Thank you for your answer. In this case, I'll leave the edited fight plan path in my FMC data folder, where the SID, STAR and approach are stored.

I hope not too much abuse by asking one last question, but I wonder if there is a way, in the FSX xml, to detect the event when the user saves the current flight, because I want at this point triggers, save with LoggerX the records all the parameters stored in L:VARS and C:XMLVARS, use my aircraft and its FMC.

As when the user resumes hhis flight flight, I will automatically rdownlaod this file to restore all parameters of the flight.

Francois
 
I wonder if there is a way, in the FSX xml, to detect the event when the user saves the current flight, because I want at this point triggers, save with LoggerX the records all the parameters stored in L:VARS and C:XMLVARS, use my aircraft and its FMC.

As when the user resumes hhis flight flight, I will automatically rdownlaod this file to restore all parameters of the flight.

Hi Francois,

If I correctly understand what you want to do, then I think it should be straightforward to set an L:Var value as a "flag" that notes when the LOGGER:write sequence is executed. Reading that file and initializing any L:Vars you want when the flight is loaded or otherwise initiated by the user is also easy.

That's what I had in mind when I wrote the XML snippet SAVE AND LOAD INIT VALUES.xml as part of the LOGGER documentation. If you want, take a look at the XML in that snippet .. it can be downloaded from the BlackBox/LOGGER website:

http://www.robbiemcelrath.com/fs/logger/download

Download the XML Examples file and see if SAVE AND LOAD INIT VALUES.xml is the sort of thing you are looking for.

The key is that the file needs to always written the same way ... the variables in the same order, so that when reading the file, you know which file records are related to which L:Vars.

Because you will be storing flight plan waypoints in which the number of waypoints will always vary from flight to flight, then I suggest that you might put the FP portion of the file as the last thing to be written to HDD file and utilize the EOF function to tell the LOGGER read sequence when to stop reading records.

Bob
 
Hi bob,

It is not quite that. In fact, I use dozens of L: vars that are the parameters of my FMS. If user saves his flight to continue the next day, when will reload, all my FMS parameters will be absent and even the plane will crash since I do not use the FSX autopilot or ATHR , because I wrote my own to create the managed mode of the Airbus, and the climb at constant N1 and variable pitch .....I have created my own A/THR.

So I would like to detect when the user recorded his flight, and at this moment, I record all my parameters.

After his flight reloaded , my gauge will read the file that I have written with these parameters for this flight.

The problem is only: how to detect that the user saves a flight (so that I can start writing the file).

Only : How detect that user save his flight ?
 
Luka, where is this event listed in the SDK? Or, is it one of the undocumented things folks occasionally find? :confused:
 
Bill, you can find it in MSDN, ESP 1.0 Core Utilities, EventsID. I've also used it long time ago in a CIVA project.

Tom
 
It is located in the "Miscellaneous Events" in both FS2004 and FSX SDK. I use this event for similar reasons as Francois.
 
Well I'll be... that's enormously helpful to be able to synch up a normal "flight save" event with a "custom file save" task!

I have to wonder why MS/ACES have hidden such stuff from view in the FSX SDK?
 
@n4gx, I'm not sure where you're looking, but I found this event shown in all SDK's (FS-2004, FSX, FSX-Acc, P3D, ESP). :)
 
Waouh !

Thank you very much Luka ! That is exactly what I searched.

Many thanks

this forum is a great community !

Francois
 
Last edited:
It's an event, not a variable.

To 'use' it, you'd have to intercept the event with your own event handler.
 
@n4gx, I'm not sure where you're looking, but I found this event shown in all SDK's (FS-2004, FSX, FSX-Acc, P3D, ESP). :)

I was looking in the events, but never "saw" it there...

...not that I see very well these days with my eyes being affected badly by diabetes... :o
 
Back
Top