Es wird xml genutzt. Ähnlichen Tipp gab es bereits hier: http://www.purebasic.fr/german/viewtopi ... =8&t=20847
Vorteile gegenüber Preferences: eigentlich keine

OOP-Schreibweise.
Erforderliche PB Version: 4.41 und höher.
Plattform: Alle
Die > 500 Zeilen Source-Datei werde ich nicht hier posten, sondern die könnt Ihr hier downloaden.
Damit Ihr eine Vorstellung habt, das Interface:
Code: Alles auswählen
Interface xmlPrefsObject
; the result of "Create", "Catch" and "Open" is the xmlObject!
;
; you can add the groupname to a keyword with a slash between:
; Keyword.s = "Group/Key"
; this will not change the actuel group!
; to move outside of any groups, an empty name ("") can be used
;
Create.i(BaseName.s) ; creates a new empty xmlPrefs
Catch.i(*adress, length) ; load a xmlPrefs from memory
Open.i(FileName.s) ; load a xmlPrefs from file
Save.i(FileName.s = "") ; save the xmlPrefs to file
Close() ; free the objectmemory
;
Comment.i(Text.s) ; writes a comment in actual group
Group.i(Name.s) ; create or change group
;
ExamineGroups.i() ; starts the enumeration of all the groups
NextGroup.i() ; retrieves information about the next group found in the enumeration
GroupName.s() ; returns the name of the current group being enumerated
;
ExamineKeys.i() ; starts the enumeration of all the keys found in the current group
NextKey.i() ; retrieves information about the next key found in the enumeration
KeyName.s() ; returns the name of the current key being enumerated
KeyValue.s() ; returns the value, in string form, of the current key being enumerated
;
DelGroup.i(Name.s) ; delete a group with all keys
DelKey.i(Keyword.s) ; delete a key
;
ReadD.d(Keyword.s, DefaultValue.d = 0) ; read a double
ReadF.f(Keyword.s, DefaultValue.f = 0) ; read a float
ReadI.i(Keyword.s, DefaultValue.i = 0) ; read a integer
ReadL.l(Keyword.s, DefaultValue.l = 0) ; read a long
ReadQ.q(Keyword.s, DefaultValue.q = 0) ; read a quad
ReadS.s(Keyword.s, DefaultValue.s = "") ; read a string
;
WriteD.i(Keyword.s, value.d) ; write a double
WriteF.i(Keyword.s, value.f) ; write a float
WriteI.i(Keyword.s, value.i) ; write a integer
WriteL.i(Keyword.s, value.l) ; write a long
WriteQ.i(Keyword.s, value.q) ; write a quad
WriteS.i(Keyword.s, value.s) ; write a string
EndInterface
Code: Alles auswählen
EnableExplicit
XIncludeFile "xmlPrefs_Include.pbi"
Define.xmlPrefsObject prefs = xmlPrefs_CreateObject()
prefs\Create("testing")
prefs\WriteS("group1/1", "100")
prefs\WriteS("group1/2", "200")
prefs\WriteS("group1/3", "300")
prefs\WriteS("group1/4", "400")
prefs\WriteS("group2/1", "100")
prefs\WriteS("group2/2", "200")
prefs\Group("group2")
prefs\WriteS("3", "300")
prefs\WriteS("4", "400")
prefs\Group("other")
prefs\WriteD("double", 1)
prefs\WriteI("integer", 1)
prefs\WriteS("string", "Feel the ..Pure.. Power")
prefs\Group("")
prefs\WriteI("x", #PB_Ignore)
prefs\WriteI("y", #PB_Ignore)
prefs\writeI("width", 640)
;prefs\WriteI("height", 480)
prefs\WriteS("title", "Testing Window")
prefs\ExamineGroups()
While prefs\NextGroup()
prefs\Group(prefs\GroupName())
Debug prefs\GroupName() + ":"
prefs\ExamineKeys()
While prefs\NextKey()
Debug prefs\KeyName() + " = " + prefs\KeyValue()
Wend
Debug "================="
Wend
prefs\Group("")
prefs\ExamineKeys()
While prefs\NextKey()
Debug prefs\KeyName() + " = " + prefs\KeyValue()
Wend
With prefs
\Group("")
OpenWindow(0, \ReadI("x"), \ReadI("y"), \ReadI("width"), \ReadI("height", 480), \ReadS("title"))
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndWith
prefs\Save("test.xml")
prefs\Close()
Thomas