Page 1 of 1

INI Memory (Library)

Posted: Thu Aug 25, 2005 6:36 am
by Shannara
http://www.purebasicnews.com/libs/INIMemory.zip

I have had a need to read INI files directly from memory. An example, would be to load an ini file from a VBin file w/o extracting it to disk, read, then delete the file. This is definately a safer solution if you want to keep your data safer from prying eyes ...

Comes with library and sample below:

Code: Select all

Procedure.s LoadString(FileName.s)
  If ReadFile(0,FileName)
    While Eof(0) = #False
      Text.s + ReadString() + #CRLF$
    Wend
    CloseFile(0)
    ProcedureReturn Text
  Else
    ProcedureReturn ""
  EndIf
EndProcedure 


myString.s = LoadString("inimemory.ini")
Debug myString
Result = INIMemory_Parse(myString)
Debug "Result: " + Str(Result)
Debug "All Groups: " + Str(INIMemory_GroupCount())
Debug "All Sections: " + Str(INIMemory_SectionCount(""))
The first thing to do is to load the ini file into memory. You can load it directly from disk or peekS it from memory and/or VBin. Then you want to call INIMemory_Parse(String). And from there, you can basically read via Long or String much like the native PB commands for Preference files. This library only allows you to read the INI groups and sections, not write.

Any questions or bugs, let me know :)