6.1-roAssociativeArray

ON THIS PAGE


This object allows you to generate an associative array (also known as a map, dictionary, or hash table), a data structure that associates objects with string keys. 

The roAssociativeArray object is created with no parameters: 

CreateObject("roAssociativeArray")

ifEnum

Reset() As Void

Resets the position to the first element of enumeration.

Next() As Dynamic

Returns a typed value at the current position and increment position.

IsNext() As Boolean

Returns True if there is a next element.

IsEmpty() As Boolean

Returns True if there is not an exact statement.

ifAssociativeArray

AddReplace(key As String, value As Object) As Void

Adds a new entry to the associative array, associating the supplied object with the supplied string. Only one object may be associated with a string, so any existing object linked to that string is discarded.

Lookup(key As String) As Object

Looks for an object in the associative array linked to the specified key. If there is no object associated with the string, then this method will return Invalid.

DoesExist(key As String) As Boolean

Looks for an object in the associative array linked to the specified key. If there is no associated object, then False is returned. If there is such an object, then True is returned.

Delete(key As String) As Boolean

Looks for an object in the associative array linked to the specified key. If there is such an object, then it is deleted and True is returned. If not, then False is returned.

Clear() As Void

Removes all objects from the associative array.

SetModeCaseSensitive() As Void

Makes all subsequent actions case sensitive. All lookups and created keys are case insensitive by default.

LookupCi(a As String) As Dynamic

Looks for an object in the array associated with the specified string. This method functions similarly to Lookup(), with the exception that key comparisons are always case insensitive, regardless of case mode.

Append(a As Object) As Void

Appends a second associative array to the first.

 


 

Example
aa = CreateObject("roAssociativeArray") 
aa.AddReplace("Bright", "Sign")
aa.AddReplace("TMOL", 42) 
print aa.Lookup("TMOL")
print aa.Lookup("Bright") 

The above script produces the following: 

42
Sign