beautypg.com

Roassociativearray (hd2000 only) – BrightSign HD2000 Object Reference Manual User Manual

Page 42

background image

roAssociativeArray (HD2000 only)

An associative array (also knows as a map, dictionary or hash table) allows objects to be associated with
string keys. The roAssociativeArray class implements the ifAssociativeArray interface.

This object is created with no parameters:
 CreateObject("roAssociativeArray")

The ifAssociativeArray interface provides:
 rotVOID AddReplace(rotSTRING key, rotOBJECT value)

o

Add a new entry to the array associating the supplied object with the supplied string. Only one

object may be associated with a string so any existing object is discarded.

 rotOBJECT Lookup(rotSTRING key)

o

Look for an object in the array associated with the specified string. If there is no object

associated with the string then an object implementing ifInt containing zero is returned.

 rotBOOL DoesExist(rotSTRING key)

o

Look for an object in the array associated with the specified string. If there is no associated

object then false is returned. If there is such an object then true is returned.

 rotBOOL Delete(rotSTRING key)

o

Look for an object in the array associated with the specified string. If there is such an object

then it is deleted and true is returned. If not then false is returned.

 rotVOID Clear(rotVOID)

o

Remove all objects from the associative array.



Example:
aa = CreateObject("roAssociativeArray")

aa.AddReplace("Bright", "Sign")
aa.AddReplace("TMOL", 42)

print aa.Lookup("TMOL")
print aa.Lookup("Bright")

Produces:

42
Sign

42

This manual is related to the following products: