collection

Top  Previous  Next

collection

coll=new("collection"[,noclose])

 

The collection object provides access to a collection of items stored by a key or index.  Keys can be up to 127 characters long.  Methods are provided to add, update, and remove elements from the collection, to find items in the collection, and to list items in the collection.  Collection storage is mapped to disk, so there can be a virtually unlimited number of elements.  If you wish to have the disk file remain open for the lifetime of the object, supply the noclose argument as true (non-zero).  Note however, that if many collections are maintained during a job, only a limited number can have the noclose option set to true, since operating systems impose a limit on how many files can be open at one time by a process.

 

Properties

count is a read-only property that holds the number of items in the collection.

 

Methods

add(ky$,value$|value) adds a string or numeric value to the collection, identified by unique key.  An error occurs if the collection already contains the specified key.

add(value$|value) adds the specified string or numeric value at a sequential index position.  No key is associated with the item.

addlist(values$[,dlm$]) adds several string values identified by sequential index.  The list of values is delimited by a linefeed character ($0A$), or by the delimiter if supplied.

clear() removes all items from the collection.

copyto(colobject) copies all elements from the this collection to the specified collection object.

exists(ky$) returns true (1) if ky$ exists in the collection, false (0) if not.

getitems$([dlm$]) returns a delimited list of values from the collection, using the specified delimiter.  If no delimiter is specified, a linefeed ($0A$) is used.

getkeys$([dlm$][,order]) returns a delimited list of keys from the collection, using the specified delimiter.  If no delimiter is supplied, then a linefeed ($0A$) is used.  If order is 0, or not supplied, the keys are returned in the order added to the collection.  The keys are returned in ascending sequence if order=1, or descending sequence if order=2.

item$(ky$|index) returns the string value identified by the key or sequential index.

item(ky$|index) returns the numeric value identified by the key or sequential index.

key$(index) returns the key of the item at the specified sequential index position.

keycur$() returns the current key, based on the last key operation.

keyfirst$() returns the first key in the collection (in ascending key sequence order).

keylast$() returns the last key in the collection.

keynext$() returns the next key in the collection, relative to the key of the last key operation.

keyprev$() returns the previous key in the collection, relative to the key of the last key operation.

remove(ky$|index) removes the item identified by its key or sequential index from the collection.

update(ky$,value$|value) updates the item identified by ky$ with value$ or value.  Adds the key if it doesn't exist.