53
TIDE and Tibbo BASIC User Manual
©2000-2008 Tibbo Technology Inc.
dim
x(
5
,
6
)
as
char
x(
0
,
0
) =
15
x(
0
,
1
) =
32
x(
0
,
2
) =
4
......
x(
5
,
2
) =
48
x(
5
,
3
) =
8
x(
5
,
4
) =
99
dim
i, j, sum
as
integer
sum =
0
for
i =
0
to
5
for
j =
0
to
4
sum = sum + x(i,j)
next
j
next
i
' here, sum would be equal to the sum of the whole array. How much is
that? Try and see.
In Tibbo Basic, you may define up to 8 dimensions in an array.
Alternative way of defining arrays
We have already explained that the following string means "an array x containing
10 elements of type byte":
dim
x(10)
as
byte
In Tibbo Basic, the same can be expressed in a different way:
dim
x
as
byte
(10)
'you can think of it as '10 times of byte type' :-)
Both ways of defining arrays are completely identical and you can even mix them
together, as we can see on the following examples of 2-dimensional arrays:
dim
i(20,10)
as
byte
'two-dimensional array, 20x10 elements
dim
i2(20)
as
byte
(10)
'same! that is, 20 groups of byte x 10 -- exactly
same meaning
dim
i3
as
byte
(20,10)
'yet another way -- same result!
Now, Tibbo Basic strings can be defined with an optional parameter specifying
maximum string length, for example:
dim
s
as
byte
(30)
'this string will have maximum length of 30 characters
(bytes)
So, how do we declare an array of string variables? Here are some examples: