Jump to content
The simFlight Network Forums

Question about offsets


Recommended Posts

Hello,

Apologies for asking a really basic question but unfortunately it's a hazard of teaching oneself...

I'm writing the contents of some L:Vars to the free FSUIPC offsets so that they can be displayed by an Opencockpits LCD card which is working well.

My question is how do I know whether to write the contents as a byte, word or dword etc? At the moment it's by trial and error by logging the offset and checking that the value is correct, although this works it's a bit time consuming and I would like to increase my knowledge.

I've read the pinned post about numbers, bits etc but haven't yet been able to link (in my mind!) this to using the appropriate type.

Any assistance will be gratefully received.

regards

Paul

Link to comment
Share on other sites

My question is how do I know whether to write the contents as a byte, word or dword etc? At the moment it's by trial and error by logging the offset and checking that the value is correct, although this works it's a bit time consuming and I would like to increase my knowledge.

Depends on the data. If it is only a flag showing whether a switch is on or off, it only really needs one bit, let alone a whole byte.

I've read the pinned post about numbers, bits etc but haven't yet been able to link (in my mind!) this to using the appropriate type.

If the program you are using for the displays doesn't tell you -- i.e. if it allows you to use what you like, then just use the type which can hold numbers as big as they are going to be. The range of values possible in an 8 bit byte is 2^8 = 256 values. In a 16 bit word is is 256 x 256, or 65536 vaslues, and so on. If the value you need is a real number with a fractional part, such as 3.142, you'd need a Float (32-bit floating point) or a double (64 bit floating point). If it's a string of characters (i.e. text) you'd need enough bytes to accommodate the number of characters in the string.

There's nothing mystical or complex about it. It is just a straightforward storage decision. Use a big a box as you need for whatever it is you want to hold in it!

Pete

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.