1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Handling FS Variables

Discussion in 'Tools programming' started by scruffyduck, 18/11/06.

  1. scruffyduck

    scruffyduck Administrator Staff Member FSDevConf team Resource contributor

    Joined:
    17/9/05
    Messages:
    25,786
    Country:
    wales
    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 :)
  2. lmoelleb

    lmoelleb

    Joined:
    23/4/05
    Messages:
    266
    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 :)
  3. scruffyduck

    scruffyduck Administrator Staff Member FSDevConf team Resource contributor

    Joined:
    17/9/05
    Messages:
    25,786
    Country:
    wales
    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.

Share This Page