Hi,
Well, now that I finally managed to get reading offsets in my think skull, I have to say that it is actually remarkably quick and easy, well done Pete and everyone else working on WideFS / FSUIPC :D
I have to agree with Pete though, there are in some cases, some REALLY strange things with VB.NET (my Language of choice), but learning a new language now, is not something that I'm up to... Who knows, maybe next year...
Anways, I'm trying to write to a offset now. I've choosen a VERY simple one to start off with (0262 - Pause Control). According to the docs, write 1 to Pause, 0 to Resume. Ok. I figured, that's easy enough....
To do this, I've used just about the same code as I use to read offsets (which, is working relatively well), and simply removed my _get, andchanged the _read to _write - ok, a bit more tweaking more than likely, but this is what I have right now:
Public Function FSUIPC_0262(ByVal PauseGame As Boolean) As Boolean
Dim dwOffset As Integer = &H262 ' We want to write to 0262
Dim dwSize As Integer = 2 ' Which, is 2 Bytes
Dim dwToken As Integer = 0
Dim dwResult As Integer = 0
' Open a link to FSUIPC.
' BTW - Pete, is it better to open a connection and leave it open
' or to open / close to FSUIPC at every call?
If myFSUIPC.FSUIPC_Open(7, dwResult) Then
' For the faint hearted and if there is ever something wrong with
' Pete's code, let's do Exception Handling.
Try
' Here, we are trying to write to FSUIPC. Because 0262 expects
' a Integer and not a Boolean, we do some magic here.
If PauseGame = True Then
' We want to Pause the Simulator, write 1 to 0262.
myFSUIPC.FSUIPC_Write(dwOffset, 1, dwToken, dwResult)
Else
' Otherwise, Resume the Similator, write 0 to 0262
myFSUIPC.FSUIPC_Write(dwOffset, 0, dwToken, dwResult)
End If
Catch e As Exception
' TODO: Exception Handling (dwResult)
Finally
' After all the writing, let's process it.
myFSUIPC.FSUIPC_Process(dwResult)
End Try
' Close up the Connection
myFSUIPC.FSUIPC_Close()
Else
' Connection to Simulator Failed
End If
End Function
Lots of comments added, to let Pete understand what's going on :D
The end result, is that the simulator is not paused when called as
FSUIPC_0262(True)
dwResult returns 0 at both the Write call, as well as the Process call as well. So it definately is being written, and it is being processed - without errors. But alas, the Sim just won't pause?
Thanks,
Chris.