Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

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")

Alternatively, an associative array can be created using brackets:

Example
aa1 = {}
aa2 = {key1:"value", key2: 55, key3: 5+3 }

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 key string. Only one object may be associated with a key, so any existing object linked to that key 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 key string, then this method will return Invalid.

Tip

In most cases, the Dot Operator can be used as shorthand for the Lookup() and AddReplace() methods when working with associative arrays.

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(key As String) As Dynamic

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

Append(aa As roAssociativeArray) 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 returns the following: 

42
Sign

 

Alternatively, you can use the Dot Operator in place of the AddReplace() and Lookup() methods:

Example
aa = {}
aa.bright = "Sign"
aa.tmol = 42 
print aa.tmol
print aa.bright
  • No labels