Some comments:
1. The easiest workaround is to write the memory to a temp file and load it (but yes, this uses the filesystem)
Code: Select all
Procedure.i CatchPreferences(*Address, Size.i)
Protected Result.i = #False
If (*Address And Size >= 0)
Protected File.s = GetTemporaryDirectory() + Str(Random(9999)) + ".ini"
Protected FN.i = CreateFile(#PB_Any, File)
If (FN)
WriteData(FN, *Address, Size)
CloseFile(FN)
Result = OpenPreferences(File)
EndIf
EndIf
ProcedureReturn (Result)
EndProcedure
If CatchPreferences(?Languages, ?Languages_End - ?Languages)
PreferenceGroup("English")
Debug ReadPreferenceString("BigString", "")
Debug ReadPreferenceString("SmallString", "")
ClosePreferences()
EndIf
End
DataSection
Languages:
IncludeBinary "Languages.txt"
Languages_End: ; need the end address of the file,
; because prefs are just a text format,
; (no EOF indicator or header with filesize)
; so we would read past the end into next memory!
EndDataSection
2. I did write a whole new prefs lib

and a "Catch" function could easily be added
http://www.purebasic.fr/english/viewtop ... 12&t=62236
BUT...
3. I don't think this solves your original goal. The PureBasic preferences library does NOT read multi-line unescaped strings. (Run the code above with your Languages.txt, it only prints "Hello World".
I don't know if the preferences/INI format is a good idea for storing multi-line unescaped text. Wikipedia says:
Some implementations also offer varying support for an escape character, typically with the backslash (\). Some support "line continuation", where a backslash followed immediately by EOL (end-of-line) causes the line break to be ignored, and the "logical line" to be continued on the next actual line from the INI file.
https://en.wikipedia.org/wiki/INI_file# ... characters
EDIT: Just want to add, I DO use this method in real programs! I embed a default language file in my code, write it to an INI on disk (which the user can edit, if they wish), parse it with the PB prefs commands, and use "\n" or "|" to represent linebreaks which I convert to #LF$.