Jump to content
The simFlight Network Forums

setup dynamic offset


mroschk

Recommended Posts

Hello,

 

i want to create a Offset for use with the .Net C# application at runtime.

 

So i have a TextBox where i can enter the Offset. Then i read this as a String Variable and then i want to create the Offset like this:

 

private Offset<short> _FsuipcOffset;

 

string _Offset = "0x4433";

_FsuipcOffset = new Offset<short>(_Offset);

 

But that code will not work because we have to enter a Hex Value like this:

 

_FsuipcOffset = new Offset<short>(0x4433);

 

How can i do this?

 

Thanks

Matthias

 

 

Link to comment
Share on other sites

Hi Matthias,

 

All you need to do is convert the string into an integer that you can pass to the offset constructor.

 

Int32 has a parse Method that will convert a string in hex into an integer.  You need to remove the '0x' though.

 

Here's the code:

string _Offset = "0x4433";
int intOffset = Int32.Parse(_Offset.Substring(2), System.Globalization.NumberStyles.HexNumber);
_FsuipcOffset = new Offset<short>(intOffset);

When you've finished with the offset, make sure you call Disconnect() before you make a new one.  If you don't, the DLL will still have a copy of it and will still read it when you call Process();

_FsuipcOffset.Disconnect();

Paul

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.