Jump to content
The simFlight Network Forums

Delphi 7


Recommended Posts

Hi, i have a problem when i read the offset 07CC, i wrote in delphi this lines

ff : single;

FSUIPC_Read($07cc, 2, @ff, result);

FSUIPC_Process(result);

label4.Caption := floatToStr((ff/65536)*360);

but i get a value that not is de HDG of Autopilot.

Thanks.

Link to comment
Share on other sites

ff : single;

FSUIPC_Read($07cc, 2, @ff, result);

I don't know Delphi -- is "single" a 16-bit unsigned integer, because if it isn't there's your first mistake? The heading at 07CC is!

Then, if you divide a 16 bit value by 65536 you are bound to get a fraction and you can't hold fractions in a 16-bit integer. Try copying the value into a floating point variable before you do the conversion.

If a Delphi "single" is a 32-bit "float" then you cannot read the 16-bit integer directly into that and expect it to make any sense. Floating point formats are completely different.

Regards,

Pete

Link to comment
Share on other sites

ff : single;

FSUIPC_Read($07cc, 2, @ff, result);

I don't know Delphi -- is "single" a 16-bit unsigned integer, because if it isn't there's your first mistake? The heading at 07CC is!

Then, if you divide a 16 bit value by 65536 you are bound to get a fraction and you can't hold fractions in a 16-bit integer. Try copying the value into a floating point variable before you do the conversion.

If a Delphi "single" is a 32-bit "float" then you cannot read the 16-bit integer directly into that and expect it to make any sense. Floating point formats are completely different.

Regards,

Pete

Roger thanks the unsigne 16 bit is "word" in delphi and now run ok. Thanks.

Link to comment
Share on other sites

label4.Caption := floatToStr((ff/65536)*360);

To remove the decimal places being displayed try this:

label4.Caption:=format('%.0f °', [(ff/65536)*360])

Now all you need to do is work out how to pad it out with zero's so you get heading '090' instead of '90' :grin:

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.