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

Handling FS Variables

scruffyduck

Administrator
Staff member
FSDevConf team
Resource contributor
Messages
34,759
Country
unitedkingdom
I may be the only one and the rest of you are already ahead of me but till now I have stored FS variables such as Lat/Lon etc in regular types like integers or doubles. I thus ended up with a nice static class full of conversions and so forth.

The other day I decided to create classes for them. Seems rather a trivial thing but.....

So a class for lat/lon/alt and so on. I have moved all the conversion and formatting code into there and now for example the latitude class stores the value as a double but can read/write/convert on the fly between decimal, string (N11*22.33), bgl packed format and FSUIPC offset format. It also stores data about the FSUIPC offset (and maybe later the relevant SimConnect event etc. Altitude can take in a BGL packed value or FSUIPC value and spit out feet or meters. The classes also handle range checking and throw exceptions if something wrong turns up. Early days yet but I think it will make programming for me a lot easier :)
 
Messages
268
Country
netherlands
Personally I use structs for this (it makes more sense to me having them as value types). I have structs for AreaG, PointG, and Latitude/Longitude.

Convertion to and from string format is done though a TypeConverter ensuring it can be displayed correctly in a property grid (back in the old days when we used property grids, I still haven't tried to find out what we use these days). I could use some more formatting options when converting to and from text, but you can't have it all :)
 

scruffyduck

Administrator
Staff member
FSDevConf team
Resource contributor
Messages
34,759
Country
unitedkingdom
Hi Lars

Well I am still using Property Grids :) I think you are probably right that value types are best for this. I haven't done much with structs in the past though I am using some custom Type converters as well.
 
Top