• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

aircraft.cfg not read entirely

Messages
1,043
Country
us-northcarolina
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 :o

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:
the "[" and "]" are suspicious ...

(within title= is not usual), perhaps the program expects a "[flightsim.x]"

just my two cents ...
 
Hi Guenther,

I wish that was it but it doesn't seem to even read that far. It reads up to "[fltsim.3]" then skips the following block and more. So what you referring too doesn't seem to be read at all. :(

title=WoA_HTAI_C208B Grand Caravan_BVN-Baron Aviation Services
model=cp
texture=BVN-Baron Aviation Services
sim=AI Cessna 208B
atc_airline=SHOW-ME
atc_id=
atc_heavy=0
ui_manufacturer=Henry Tomkiewicz
ui_type=Cessna 208B
ui_variation=Baron Aviation Services
description=Painted by Josh Kubale
atc_parking_types=CARGO
atc_parking_codes=BVN
 
Update: I just checked the file in an hexa editor. The line "[fltsim.3]" is properly followed by 0A0D, chr(13) or CRLF as all other entries are.
 
Yes I know and I thought of it but then laziness got me to copy/paste some code I already had :D

Oh will, you are right...I'll do a bit more typing.
I'm still curious to know why my bug is happening. I've never seen that before.
 
UPDATE: problem solved...and no you can't ask what it was :D

Please Mr. Admin delete this worthless thread.
 
I don't know what is so special about an aircraft.cfg file, I wrote a little program a long time ago that loads up a file and displays it in a window. I took an aircraft.cfg file and loaded with it to see if there were errors.

28hzbt4.png


It loaded the entire file just fine, the little '>>' means the line continues.

I could of just read it as a text file and got what I needed but you are using what appears to be Visual Basic code ... I am a C++ guy.
 
Back
Top