Private Type TCAS_DATA
id As DWORD 'This one (DWORD), as I saw, is declared within the FSUIPC.bas (module).., so it not even standard in VB......
lat As Single
lon As Single
alt As Single
hdg As Integer
gs As Integer
vs As Integer
idATC As String * 15
bState As Byte
com1 As Integer
End Type
Dim AI() As String, AI2() As TCAS_DATA 'Define AI as a string array and AI2 as a TCAS_DATA array
ReDim AI2(0 To 96) 'Define the length of the AI2 array (96)
If FSUIPC_Read(&HF080, 3840, VarPtr(AI2), dwResult) Then 'Read data from offset F080 with length 3840 (96x40) into array AI2... (but doesn't work)
If FSUIPC_Process(dwResult) Then 'If the processing returned no error
ReDim AI(0 To 96, 0 To 6) 'Define the length (2D) of the AI array, this is the array in which the usable data (for my application) will be stored.
a = 0
For i = 0 To 96 'Cycle all the 96 entries of AI2.
If AI2(i).id <> 0 Then
AI(a, 0) = AI2(i).id 'Assign the needed values to the AI array
AI(a, 1) = AI2(i).lat
AI(a, 2) = AI2(i).lon
AI(a, 3) = AI2(i).alt
AI(a, 4) = AI2(i).hdg
AI(a, 5) = AI2(i).gs
AI(a, 6) = AI2(i).idATC
a = a + 1
End If
Next
End If
End If
This doesn't work.... :( :cry:
This is what goes wrong:
When running this code, VB returnes a 'Type mismatch' and selects the AI2 in between the VarPtr
VarPtr appears to be a function (standard in VB) to convert the supplied variable into a Long type (because this is needed by the FSUIPC_Read function). The variable needed to be supplied for the VarPtr function, can be anything, so in my opinion it is weird to have a type mismatch....