54
Programming with TIDE
©2000-2008 Tibbo Technology Inc.
dim
s(20,10)
as
string
(30)
'two-dimensional array of 30-byte strings,
20x10 elements
dim
s2(20)
as
string
(30)(10)
'same!
dim
s2
as
string
(30)(20,10)
'same!
Arrays introduce slight overhead
Each array occupies more space than the sum total of space needed by all
elements of an array. This is because each array also includes housekeeping data
that, for instance, defines how many elements are there in an array, array of what
type that is, etc.
4.2.4.6
Structures
Beginning with
V2
, Tibbo Basic supports structures. Structure is a combinatorial
user-defined data type that includes one or several member variables. Structures
are declared using
statements, as shown in the example
below:
'this is a structure with three members
type
my_struct
x
as
byte
y
as
Long
s
as
string
end
type
In the above example, we declared a structure my_struct that has three member
variables: x, y, and s. This is just a declaration -- you still have to define a variable
with the new type you have created if you want to use the structure of this type in
your program:
dim
var1
as
my_struct
'this is how you define a variable with type
'my_struct'
After that, you can address individual elements of the structure as follows:
var1.x=5
var1.y=12345678
var1.s="Test"
Structures you define may include members that are arrays or other structures.
Structure variables like var1 above can be arrays as well, of course. In total, Tibbo
94