INIFile class

I’m porting a very old VB6 code to XOJO, i need to write and read from INIfile , i want it to be cross-platform.
after several hours of research i found that there was an INIFile class , it was removed for some reason :frowning:
is there a way to find this class because i really need it
Thank you !

This one from @Christian_Schmitz ?
But it’s Windows only.

1 Like

I use a very old XML Preferences module that is cross platform and will save an .ini file for Windows and a .pref file for Mac OS. The original author has given permission to share and modify. Here is a link:


Thank you for your reply, i don’t think this is it because the one i read about was cross-platform it was removed from xojo january 2023

Thank you for your help, i will try it.

I have this very old INI_Read method written by (I don’t even know who that is).
I used that code 12 years ago :older_man:t2:

Public Function GetINIEntry(Input As String, EntryName As String, HeaderName As String, Encoding As TextEncoding = Nil, NoValue As String = "") As String
  // "Some Value" = GetINIEntry(GetFolderItem("Setup.ini"), "Some Option", "Setup")
  // INI files are tricky, so baer with me if something goes wrong.

  If Input = "" Then Return NoValue
  Dim Enc As TextEncoding = Encoding
  If Enc = Nil Then Enc = Encodings.UTF8 //Default INI file encoding
  Dim Data As String = Input 'Input.ReadAll(Enc) //It's ok if Enc is nil...
  //  Done loading data, now parse it (ugh! I hope this works)...
  //  Parses the most common INI version (which I forget which is).
  Data = ReplaceLineEndings(Data, EndOfLine)
  Dim i As Integer = 1, Line, CurrentHeader, Name, Value As String
  While i <= CountFields(Data, EndOfLine)+1
    Line = NthField(Data, EndOfLine, i)
    If Trim(Line) <> "" Then
      If Left(Line, 1) <> ";" Then
        If Left(Line, 1) = "[" Then //Header detected, set current header and pass the header...
          CurrentHeader = Mid(Line, 2, InStr(Line, "]")-2) //Get the header name.
          Line = Mid(Line, Len("["+CurrentHeader+"]")+1) //Forward line to just past the header.
          If Trim(Line) = "" Then
            i = i + 1
            Continue While
          End If
        End If
        If CurrentHeader <>  HeaderName then
          i= i + 1
          Continue While
        End If
        Name = NthField(Line, "=", 1) //Name of the setting.
        Value = Mid(Line, Len(Name+"=")+1)
        If Right(Name, Len(" ")) = " " Then //Hmmm... someone put a space :/
          Name = Left(Name, Len(Name)-Len(" "))
          Value = Mid(Value, Len(" ")+1)
        End If
        If CurrentHeader = HeaderName And Name = EntryName Then Return Value
      End If
    End If
    i = i + 1
  Return NoValue
End Function


Thank you for your help, .ini files will never die :skull_and_crossbones:

They’re zombies.:smiley:

I made an INI to JSON class right now, mostly untested, but I loaded this INI test successfully:

And it became this JSON:

  "network": {
    "mac": "01:23:45:67:89:AB",
    "gateway": "",
    "ip": "",
    "hosts allow": ""
  "network2": {
    "mac": "ee:ee:ee:ee:ee:ee",
    "subnet mask": "",
    "hosts allow": ""
  "misc": {
    "string": "123456789012345678901234567890123456789001234567890",
    "string2": "a string with spaces in it"
  "mime types": {
    "default": "text/plain",
    "htm": "text/html",
    "bin": "application/octet-stream",
    "pdf": "application/pdf"
  "/": {
    "handler": "default",
    "error document 403": "/errordoc/403.htm"
  "/www.ini": {
    "handler": "default"
  "/data": {
    "handler": "default"
  "/data/private": {
    "handler": "prohibit",
    "error document 403": "/data/private/403.htm"
  "/data/noaccess.txt": {
    "handler": "prohibit"
  "/status": {
    "handler": "status"
  "/cgi": {
    "handler": "cgi"
  "/src": {
    "handler": "temporary redirect",
    "location": ""
  "/upload": {
    "allow put": "true"

Thank you for your help , unfortunately can’t use it :frowning: we have to keep some backward compatibility for now. :skull_and_crossbones:

It reads your INI file and you can do anything. I don’t get it. Play with it.

1 Like

we need to read and write

I will add write. I just need a cup of coffee. :smile:

1 Like

:coffee: on us :smile:

No need, I have lots of great coffee in here. :wink:


Download it again. Upgraded to 1.1
I hope I got it right the first time because I need to go. :smiley:


I remember a couple of 3rd party libs but I cant find them now.
Some of the many users leaving xojo in the last years have deleted their 3rd party resources :frowning:

1 Like

Mine is working very well. I tested it with more care few minutes ago and surprisingly It worked like a Golfer doing a Hole in One.

The link is above: INIFile class - #9 by Rick_A

At that time it was a fresh 1.0, now it is 1.2


@Rick_Araujo is a Master. (Tournament reference.) Always appreciate your contributions.


Thank you @Rick_Araujo, your help is much appreciated!

1 Like

And 1.3 is there now. :rofl:

Covering more use cases and more commented tests exemplifying the use.