[Gambas-user] Settings: how to get (unknown) Keys?
wig
wig at ...1809...
Wed Jun 18 15:08:23 CEST 2014
How the get the (unknown keys) from a Settings file?
Terminology of Keys and "Slot" for the group of keys in a settings file
taken from documentation;
This gives the names of the slots:
Dim SettingsToImport As New Settings(User.Home &/
".config/gambas3/gambas3.conf")
Dim sKeySlot As String
Dim iSlotCounter As Integer
For Each sKeySlot In SettingsToImport.Keys
Debug sKeySlot
Inc iSlotCounter
Next
Debug " - - - - " & iSlotCounter
Works fine, gives me all the slotnames, and the count of e.g.23:
> Editor
> FColorChooser
> FConnectionEditor
...
> gb.form.mdi/FShortcut
> gb.form.mdi/FToolbarConfig
> gb.form.mdi/Toolbars/main
> - - - - 23
Next step; I want to have the keys themselves. But how? (assuming I do
not know the keynames)
Dim SettingsToImport As New Settings(User.Home &/
".config/gambas3/gambas3.conf")
Dim sKey As String
Dim iKeyCounter As Integer
Dim hSettingsKeys As _Settings_Keys ' what I found in gb.settings docum.
For Each sKeySlot In SettingsToImport.Keys
Debug sKeySlot
Inc iSlotCounter
hSettingsKeys = SettingsToImport.Keys[sKeySlot] ' docum says
hSettings.Keys [ Parent As String ]
For Each sKeySlot In hSettingsKeys
Inc iKeyCounter
Debug iKeyCounter & ": " & sKey
Next
Next
Doesn't crash, doesn't freeze, but gives the output:
> Editor
> 1: Font
> 2: KeywordsUseUpperCase
> KeywordsUseUpperCase
That's all, it stops.
(I want to import a Settings file, not use it for my app itself; I know
how to save and use settings for my app).
This in Gambas 3.4.1 on OpenSuse 13.1/KDE
WiG.
More information about the User
mailing list