Result = OpenPreferences(Filename$ [, Flags])Description
Opens a previously existing preference file.
Filename$ The filename of the preference file. Flags (optional) It can be a combination of the following values:#PB_Preference_NoSpace: no spaces will be put around the equal sign joining key and values. It can be useful when dealing with external preferences files which doesn't accept spaces around equal sign. #PB_Preference_GroupSeparator: add an empty line between the groups to ease readability of the file.
Nonzero if the file has been successfully opened, zero otherwise.
If the file wasn't found or can't be opened, it is still possible to use the read functions and it will return the specified default value. It is very useful to initialize in one step the program variables. The functions like ReadPreferenceString() can be used to read the preference values stored in the file.
To remove a key or a group, use RemovePreferenceKey() and RemovePreferenceGroup(). To create or change the current group, use PreferenceGroup().
It is possible to change existing values with WritePreferenceString() and similar functions.
Once all write operations are done, ClosePreferences() needs to be called to really write the preferences back to disk (if it has been modified inbetween).
; Open a preference file OpenPreferences(#PB_Compiler_Home +"Examples\Sources\Data\test.pref") ; Examine Groups ExaminePreferenceGroups() ; For each group While NextPreferenceGroup() texte$ = texte$ + PreferenceGroupName() + #LF$ ; its name ; Examine keys for the current group ExaminePreferenceKeys() ; For each key While NextPreferenceKey() texte$ = texte$ + PreferenceKeyName() + " = " + PreferenceKeyValue() + #LF$ ; its name and its data Wend texte$ = texte$ + #LF$ Wend ; Display all groups and all keys with datas MessageRequester("test.pref",texte$) ; Close the preference file ClosePreferences()