|

 | [back to Using the object-oriented features of LotusScript]
The BetterList class
Public Class BetterList
Private m_list List As Variant
Private m_count As Integer
Property Get Count As Integer
End Property
Public Function DeleteList
End Function
Public Function DeleteItem(key As String) As Integer
'if the key is in the list, erase the object
If ( Iselement(m_list(key)) ) Then
Erase m_list(key)
m_count = m_count-1
rval = True
Else
'if there's no such key, warn of an error
rval = False
Print "Item " & key & " not found. It could not be deleted."
End If
Public Function AddItem(key As String, item As ListItem) As Integer
'just add the item if the key doesn't exist
If ( Not Iselement(m_List(key)) ) Then
Set m_list(key) = item
m_count = m_count+1
Else
'if the key does exist, erase the current object in the list
'and add the new one
Erase m_List(key)
Set m_list(key) = item
End If
Public Function GetItem(key As String) As Variant
Dim itm As ListItem
On Error ErrListItemDoesNotExist Goto NoSuchItem
Set GetItem = m_list(key)
OK:
NoSuchItem:
'return a value of Nothing if the key was not found
Print "List item " & key & " not found."
Set itm= Nothing
Set GetItem = itm
Resume OK
'see if there's an object in the list for a given key
Public Function IsInList(key As String) As Integer
If ( Iselement(m_List(key)) ) Then
Else
End If
End Class
 |
 |  |
|