Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Config File
#11
I didn't read most of the posts but if it's being configured within the client and you aren't actually going to be editing the ini file then why not just save/load it as a binary file and instead of adding that extra code for read/get/write/whatever you can just do it like maps and stuff. This is what I do.

Code:
Public Sub LoadUserData()
Dim FileName As String
Dim f As Long
    
    FileName = App.Path & "\Data Files\config.dat"
    
    If Not FileExist("Data Files\config.dat") Then
        Call SetStatus("Creating user data file...")
        Call SaveUserData
        Exit Sub
    Else
        f = FreeFile
        Open FileName For Binary As #f
            Call SetStatus("Loading user data...")
            Get #f, , UserData.Pinned
            Get #f, , UserData.Save
            Get #f, , UserData.Username
            Get #f, , UserData.Password
        Close #f
    End If
    
    DoEvents
End Sub

Public Sub SaveUserData()
Dim FileName As String
Dim f As Long

    FileName = App.Path & "\Data Files\config.dat"

    f = FreeFile
    Open FileName For Binary As #f
        Put #f, , UserData.Pinned
        Put #f, , UserData.Save
        Put #f, , UserData.Username
        Put #f, , UserData.Password
    Close #f
End Sub

Public Sub ClearUserData()
    UserData.Pinned = 0
    UserData.Save = 0
    UserData.Username = vbNullString
    UserData.Password = vbNullString
End Sub

Type UserDataRec
    Pinned As Byte
    Save As Byte
    Username As String * NAME_LENGTH
    Password As String * NAME_LENGTH
    VitalConfig As Byte
End Type

Then in Sub Main I just clear it then load it and when I want to save it.. UserData.Username = "text".... Save UserData.

Better?
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)