Xbasic

Collections

Description

A collection is an Xbasic datatype, similar to an array, but whose elements are referenced with a "key" rather than an index. A key is a value (character, numeric or date) that uniquely identifies an element in a collection.

For example, in the following collection, the key BB refers to the element Bryan Boyd.

For example, say that the collection shown below was called mycollection. The command: mycollection.GET("BB") refers to the collection element Bryan Boyd.

Key
Data
"FJ"

"Fred Jones"

"BB"

"Bryan Boyd"

"KL"

"Kim Lee"

"KB"

"Karen Boyd"

"EL"

"Erica Loyd"

By contrast, in an array, elements are referred to by index number. For example, say that the array shown below was called " myarray ". The command: myarray2 refers to the 2 nd array element.

Index
Data
1

"Fred Jones"

2

"Bryan Boyd"

3

"Kim Lee"

4

"Karen Boyd"

5

"Erica Loyd"

You do not have to declare the size of a collection in advance. The following command defines a collection. There is no maximum number of entries in the collection (other than limits set by available memory).

dim mycollection as U

See Also