Jump to content
The simFlight Network Forums

Problem With Saving A Flight


CougarFool

Recommended Posts

Hi everyone,

I have a problem when using offset 3F00 to save the flight.

My little application has a button that, when clicked, should save the flight.

It works the first time and saves the flight correctly.

Each subsequent click does not save the flight. I have to restart my application to get it to save again.

The variables are:

Private Const FltName As String = "NewAutoSave"
'save flight group
Dim oSaveName As Offset(Of String) = New FSUIPC.Offset(Of String)("saveflt", &H3F04, 252)
Dim oSaveCmd As Offset(Of Short) = New FSUIPC.Offset(Of Short)("saveflt", &H3F00)

And the Click event is:

Try
	If FSUIPCConnection.IsOpen Then
		oSaveName.Value = FltName
		oSaveCmd.Value = 1
		'write
		FSUIPCConnection.Process("saveflt")
		lblSaved.Text = $"Saved at:{Now.ToShortTimeString}" 'update Form label
	End If
Catch fsex As FSUIPCException
	MsgBox(fsex.Message)
Catch ex As Exception
	MsgBox(ex.Message)
End Try

Each Click does update the 'Saved at:' label so it is executing the code above it without throwing an Exception.

I have tried running the application as Administrator and there is no difference.

I have tried executing the code on a BackGroundWorker but there is no differerence.

I'm hoping that there is a obvious mistake I've made in my code but I can't see it!

Any help would be appreciated from fellow developers!

Nigel.

Link to comment
Share on other sites

The dll isn't writing offset 0x3F00 the second and subsequent times because the value has not changed. It was 1, but it's still 1 so no write takes place. The offset value is read instead.

To make this work you need to mark the offset as write-only (set third parameter to 'True'). These type of offsets will be written every time you process them, regardless of whether the value has changed or not. They are never read.

Dim oSaveCmd As Offset(Of Short) = New FSUIPC.Offset(Of Short)("saveflt", &H3F00, True)

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.