Object Arrays

In addition to storing numeric and string variables, arrays may also store pointers to objects. Bitmaps and SQLite Cursors are two examples of objects. It is easy to see how an array of bitmaps might be useful.

The syntax is identical to using numeric arrays.

Dim bmTree(2)

bmTree(0) = LoadBitmap("graphics/tree1.png")
bmTree(1) = LoadBitmap("graphics/tree2.png")
bmTree(2) = LoadBitmap("graphics/tree3.png")

Since object arrays only hold a pointer to an object, multiple elements in an array may hold pointers to the same object.

Dim bmTreeLoc(20)

For i = 0 to 20
bmTreeLoc(i) = bmTree(Rnd(3))

An array becomes an object array the first time an object pointer is stored in one of it's elements. Once an object pointer is stored in an array, that array may only be used to store that type of object pointer.

Arrays and Subscripts

Become a Patron