Created by
SeanB
| Struct tKeyValue
String sKey
String sValue
End_Struct
Class cDictionary is a cObject
Procedure construct_object
Forward Send Construct_Object
Property tKeyValue[] pDictionary
End_Procedure
Function CompareKey tKeyValue keyValue1 tKeyValue keyValue2 Returns Integer
If (keyValue1.sKey > keyValue2.sKey) Function_Return (GT)
If (keyValue1.sKey < keyValue2.sKey) Function_Return (LT)
Function_Return (EQ)
End_Function
Procedure Set key String sKey String sValue
tKeyValue[] Dictionary
tKeyValue KeyValueItem
Integer iSearchIndex
Integer iMax
Move (Uppercase(sKey)) to sKey
Get pDictionary to Dictionary
Move sKey to KeyValueItem.sKey
Move sValue to KeyValueItem.sValue
Move (SearchArray(KeyValueItem, Dictionary, Self, (RefFunc(CompareKey)))) to iSearchIndex
Move (SizeOfArray(Dictionary)) to iMax
If (iSearchIndex = -1) Move KeyValueItem to Dictionary[iMax]
Else Move KeyValueItem to Dictionary[iSearchIndex]
Set pDictionary to Dictionary
End_Procedure
Procedure delete_data
tKeyValue[] Dictionary
Set pDictionary to Dictionary
End_Procedure
Function key String sKey Returns String
Integer iSearchIndex
tKeyValue[] Dictionary
tKeyValue KeyValueItem
Move (Uppercase(sKey)) to sKey
Move sKey to KeyValueItem.sKey
Get pDictionary to Dictionary
Move (SearchArray(KeyValueItem, Dictionary, Self, (RefFunc(CompareKey)))) to iSearchIndex
If (iSearchIndex = -1) Function_Return (False)
Function_Return Dictionary[iSearchIndex].sValue
End_Function
End_Class
|