I'm not sure if it's a file issue, a VB issue or a programmer issue. If you ask me I would opt for the 3rd one 
Here is the issue, this procedure opens aircraft.cfg files and parses the data to save what I need into another file. In that particular file I am attaching (might be others but I caught this one) it reads up to the last line of the [fltsim.2] block then it reads the line [fltsim.3] but skips directly to the data of block [fltsim.8].
I have checked for funky characters and all I could think of and I'm now out of ideas.
As you can see in the code I even tried writing in a test file all that is read in, well I'm missing few blocks in the output.
If you don't mind giving it a look and testing it...anyone, please.
Thanks in advance
P.S. Hans I hope you are around for this one
The attached file was renamed since the server doesn't accept .cfg files.
Here is the issue, this procedure opens aircraft.cfg files and parses the data to save what I need into another file. In that particular file I am attaching (might be others but I caught this one) it reads up to the last line of the [fltsim.2] block then it reads the line [fltsim.3] but skips directly to the data of block [fltsim.8].
I have checked for funky characters and all I could think of and I'm now out of ideas.
As you can see in the code I even tried writing in a test file all that is read in, well I'm missing few blocks in the output.
If you don't mind giving it a look and testing it...anyone, please.
Thanks in advance
P.S. Hans I hope you are around for this one
The attached file was renamed since the server doesn't accept .cfg files.
Code:
Public Function Parse_CFG()
Dim sFilepath As String
Dim sDir As String
Dim iReadNum As Integer
Dim sLine As String
Dim sATC_Airline As String
Dim UI_Var As String
Dim sTitle As String
Dim fltsim As String
Dim a_Airline() As String
Dim a_Aircraft() As String
Dim a_Relationship() As String
Dim n As Integer
Dim bFstTime1 As Boolean
Dim bFstTime2 As Boolean
Dim bDuplicate1 As Boolean
Dim bDuplicate2 As Boolean
Dim sSpeed As String
Dim sRange As String
Dim sCeiling As String
Dim sSpan As String
On Error GoTo Parse_CFGERR
sFilepath = Read_INI(gsIniFileFullPath, "Path", "FSAircraftPath", "")
bFstTime1 = True
bFstTime2 = True
ReDim a_Airline(0)
ReDim a_Aircraft(0)
ReDim a_Relationship(0)
sDir = Dir(sFilepath, vbDirectory)
Do While sDir <> ""
If sDir <> "." And sDir <> ".." And GetAttr(sFilepath & sDir) = vbDirectory Then
If FileExist(sFilepath & sDir & "\Aircraft.cfg") Then
iReadNum = FreeFile()
Open sFilepath & sDir & "\Aircraft.cfg" For Input As #iReadNum
If sDir = "WoA_HTAI_C208B Grand Caravan" Then Open App.Path & "\test.txt" For Output As #25
' If sDir = "WoA_HTAI_C208B Grand Caravan" Then Stop
fltsim = ""
sATC_Airline = ""
sTitle = ""
UI_Var = ""
Do While Not EOF(iReadNum)
Line Input #iReadNum, sLine
sLine = Trim(sLine)
If sDir = "WoA_HTAI_C208B Grand Caravan" Then Print #25, sLine
' Debug.Print sLine
'If sLine = "[fltsim.3]" Then Stop
If Len(sLine) Then
' Handle airline
If InStr(1, sLine, "[fltsim.") Then
If fltsim <> sLine Then
If Len(sATC_Airline) Then
' Add to array
If sATC_Airline = "SHOW-ME" Then Stop
GoSub AddAirline
sATC_Airline = ""
End If
' Handle aircraft
If Len(sTitle) Then
' Add to array
GoSub AddAircraft
sTitle = ""
UI_Var = ""
sATC_Airline = ""
End If
End If
fltsim = sLine
End If
End If
' Gets the values
If InStr(1, LCase(sLine), "atc_airline=") Then If Len(Right(sLine, Len(sLine) - 12)) Then sATC_Airline = Trim(Right(sLine, Len(sLine) - 12))
If InStr(1, LCase(sLine), "ui_variation=") Then If Len(Right(sLine, Len(sLine) - 13)) Then UI_Var = Trim(Right(sLine, Len(sLine) - 13))
If InStr(1, LCase(sLine), "title=") Then sTitle = Trim(Right(sLine, Len(sLine) - 6))
Loop
' Add last record to array
If Len(sATC_Airline) Then GoSub AddAirline
If Len(sTitle) Then GoSub AddAircraft
sATC_Airline = ""
sTitle = ""
UI_Var = ""
Close #iReadNum
End If
End If
sDir = Dir
Loop
Close #25
WriteFileAirorts a_Airline
WriteFileAircrafts a_Aircraft
WriteRelationship a_Relationship, a_Aircraft
MsgBox "Stock data was reloaded.", vbInformation
Exit Function
' =========================================================
AddAirline:
' Look for duplicates
sATC_Airline = UCase(sATC_Airline)
For n = 0 To UBound(a_Airline)
If a_Airline(n) = sATC_Airline Then bDuplicate1 = True
Next n
If Not bDuplicate1 Then
If Not bFstTime1 Then
ReDim Preserve a_Airline(UBound(a_Airline) + 1)
Else
bFstTime1 = False
End If
a_Airline(UBound(a_Airline)) = sATC_Airline
Else
bDuplicate1 = False
End If
Return
AddAircraft:
' Look for duplicates
For n = 0 To UBound(a_Aircraft)
If a_Aircraft(n) = sTitle Then bDuplicate2 = True
Next n
' Add to array
If Not bDuplicate2 Then
If Not bFstTime2 Then
ReDim Preserve a_Aircraft(UBound(a_Aircraft) + 1)
ReDim Preserve a_Relationship(UBound(a_Relationship) + 1)
Else
bFstTime2 = False
End If
Mid(sTitle, 1, 1) = UCase(Mid(sTitle, 1, 1))
a_Aircraft(UBound(a_Aircraft)) = sTitle & " [" & UI_Var & "]" & "/~/" & sDir
' Relationship
If UCase(sATC_Airline) = "" Then sATC_Airline = "GENERAL AVIATION"
a_Relationship(UBound(a_Relationship)) = UCase(sATC_Airline) & "/~/" & sTitle & " [" & UI_Var & "]" & "/~/" & sDir
Else
bDuplicate2 = False
End If
Return
Exit Function
Parse_CFGERR:
If Err.Number <> 32755 Then MsgBox Err.Description, , "Parse_CFG"
On Error GoTo 0
End Function
Last edited:


