Hello,
I wonder if any VBasic programmer can help me in writing the code for my applycation to set the aircraft position through FSUIPC. I got a "developer key" from Pete but debugging is very difficult as I need to run a full compiled version for FSUIPC to accept my application's requests.
My application is scenery generation programme and I only need to read and to write the aircraft lat/lon. I followed the examples in the FSUIPC SDK and I can read the aircraft position. But when I try to set the aircraft position there is an overflow and my application crshes.
Following is the routines to read (which works fine) and to write (which does not) the latitude. Any comment would be most apreciated.
Regards, Luis
Public Function fsUIPCGetLatitude(Latitude As Double) As Integer
Dim Fake64Bit As Currency
Dim dwResult As Long
fsUIPCGetLatitude = 0
If FSUIPC_Read(&H560, 8, VarPtr(Fake64Bit), dwResult) Then
If FSUIPC_Process(dwResult) Then
Latitude = Fake64Bit * 10000#
Latitude = Latitude * 90# / (10001750# * 65536# * 65536#)
Else
fsUIPCGetLatitude = 1
End If
Else
fsUIPCGetLatitude = 1
End If
End Function
Public Function fsUIPCSetLatitude(Latitude As Double) As Integer
Dim Fake64Bit As Currency
Dim dwResult As Long
fsUIPCSetLatitude = 0
Latitude = (Latitude / 90#) * (10001750# * 65536# * 65536#)
Fake64Bit = Latitude / 10000#
If FSUIPC_Write(&H560, 8, VarPtr(Fake64Bit), dwResult) Then
If FSUIPC_Process(dwResult) Then
Else
fsUIPCSetLatitude = 1
End If
Else
fsUIPCSetLatitude = 1
End If
End Function