[Gambas-user] BUG: Settings.Keys (gb.settings)

Tobias Boege taboege at ...626...
Thu Nov 27 19:16:17 CET 2014


On Thu, 27 Nov 2014, Lewis Balentine wrote:
> Reference: http://gambaswiki.org/wiki/comp/gb.settings/settings/keys
> 
> Settings.Keys (gb.settings)
> Property Read Keys As _Settings_Keys
> Return a virtual object used for enumerating all the keys used by the 
> setting file.
> 
> Wrong: It returns a array of strings that are the "Slot Names".
> 

It's not an array, it's a _Settings_Keys object.

> Key Definition: A value line, which is a "Key=Value" pair.
> Slot Definition: A slot line, which begins with a "[" character, and 
> ends with a "]" character.
> 

Hmm, I'd define them a little differently: a "key" is not a value line but
only the key part of a value line. "Slot" is not a slot line but the slot
line minus the brackets.

Now we have the nit-picking out of the way, I will say that you are right to
a degree. In the _Settings_Keys object you can enumerate the slot names. But
in the second iteration, if you have all the slot names, you can use
_Settings_Keys to enumerate all the keys under each slot which sums to all
the keys there are:

  Dim sSlot, sKey As String

  For Each sSlot In Settings.Keys
    For Each sKey In Settings.Keys[sSlot]
      Print sSlot &/ sKey
    Next
  Next

If I was to vote, I'd not change the documentation as _Settings_Keys
ultimately allows you to enumerate all the keys. Obviously (?) the keys
are namespaced using a slot, so to enumerate all the keys, it makes sense
to require that we go through the namespace level first.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk




More information about the User mailing list