Settings: Add a few methods and properties.
[GB.SETTINGS] * NEW: Settings.Count is a new property that returns the total number of settings. * NEW: Settings.Exist() is a new method that return if a specific settings key is set. * NEW: Settings.Keys.Count is a new property that returns the number of children slots. * NEW: Settings.Keys.Exist() is a new method that returns if a specific child slot exists. * NEW: Settings.Keys.All is a new property that returns an array of all children slot keys.
This commit is contained in:
parent
7923d08a41
commit
4b34a2b9d5
2 changed files with 79 additions and 13 deletions
|
@ -15,6 +15,7 @@ Static Private $iPos As Integer
|
|||
|
||||
Property Read Keys As _Settings_Keys
|
||||
Property Read Path As String
|
||||
Property Read Count As Integer
|
||||
|
||||
Private $sPath As String
|
||||
Private $sTitle As String
|
||||
|
@ -243,6 +244,20 @@ Public Function _get(Key As String, Optional {Default} As Variant) As Variant
|
|||
|
||||
End
|
||||
|
||||
Public Sub Exist(Key As String) As Boolean
|
||||
|
||||
Dim hSlot As Collection
|
||||
Dim sSlot As String
|
||||
'Dim dDate As Date
|
||||
|
||||
sSlot = GetSlot(Key)
|
||||
Key = File.Name(Key)
|
||||
|
||||
hSlot = $cSlot[sSlot]
|
||||
If hSlot And If hSlot.Exist(Key) Then Return True
|
||||
|
||||
End
|
||||
|
||||
Private Sub SameSetting(vOld As Variant, vNew As Variant) As Boolean
|
||||
|
||||
Dim I As Integer
|
||||
|
@ -856,3 +871,16 @@ Static Public Sub FromString(Value As String) As Variant
|
|||
Return vVal
|
||||
|
||||
End
|
||||
|
||||
Private Function Count_Read() As Integer
|
||||
|
||||
Dim cCol As Collection
|
||||
Dim iCount As Integer
|
||||
|
||||
For Each cCol In $cSlot
|
||||
iCount += cCol.Count
|
||||
Next
|
||||
|
||||
Return iCount
|
||||
|
||||
End
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
Export
|
||||
Create Static
|
||||
|
||||
Property Read Count As Integer
|
||||
Property Read All As String[]
|
||||
|
||||
Public _Slot As Collection
|
||||
Public _Parent As String
|
||||
|
||||
|
@ -19,28 +22,38 @@ Public Sub _get(Parent As String) As _Settings_Keys
|
|||
|
||||
End
|
||||
|
||||
Public Sub _next() As String
|
||||
Private Sub GetKeys() As Boolean
|
||||
|
||||
Dim vVal As Variant
|
||||
Dim cCol As Collection
|
||||
|
||||
If _Parent Then
|
||||
Try cCol = _Slot[_Parent]
|
||||
Else
|
||||
cCol = _Slot
|
||||
Endif
|
||||
If Not cCol Then Return True
|
||||
|
||||
$aKeys = New String[]
|
||||
For Each vVal In cCol
|
||||
If Not _Parent And If vVal.Count = 0 Then Continue
|
||||
$aKeys.Add(cCol.Key)
|
||||
Next
|
||||
$aKeys.Sort
|
||||
|
||||
Debug $aKeys.Join()
|
||||
|
||||
End
|
||||
|
||||
Public Sub _next() As String
|
||||
|
||||
Dim sKey As String
|
||||
|
||||
If IsNull(Enum.Index) Then
|
||||
If _Parent Then
|
||||
Try cCol = _Slot[_Parent]
|
||||
Else
|
||||
cCol = _Slot
|
||||
Endif
|
||||
If Not cCol Then
|
||||
If GetKeys() Then
|
||||
Enum.Stop
|
||||
Return
|
||||
Endif
|
||||
$aKeys = New String[]
|
||||
For Each vVal In cCol
|
||||
If Not _Parent And If vVal.Count = 0 Then Continue
|
||||
$aKeys.Add(cCol.Key)
|
||||
Next
|
||||
$aKeys.Sort
|
||||
Enum.Index = 0
|
||||
Endif
|
||||
|
||||
|
@ -53,3 +66,28 @@ Public Sub _next() As String
|
|||
Endif
|
||||
|
||||
End
|
||||
|
||||
Public Sub Exist(Key As String) As Boolean
|
||||
|
||||
If Not $aKeys Then GetKeys()
|
||||
If $aKeys Then Return $aKeys.Exist(Key)
|
||||
|
||||
End
|
||||
|
||||
Private Function Count_Read() As Integer
|
||||
|
||||
If Not $aKeys Then GetKeys()
|
||||
If $aKeys Then Return $aKeys.Count
|
||||
|
||||
End
|
||||
|
||||
Private Function All_Read() As String[]
|
||||
|
||||
If Not $aKeys Then GetKeys()
|
||||
If $aKeys Then
|
||||
Return $aKeys.Copy()
|
||||
Else
|
||||
Return New String[]
|
||||
Endif
|
||||
|
||||
End
|
||||
|
|
Loading…
Reference in a new issue