memory. With the following example definition
Dim x(10) As Integer
a tenfold memory space has been arranged for variable x. The first memory space can be addressed
by
], the second by
X[0
dimensions can also be chosen. The memory space of C-Control Pro is the only limit.
Multi dimensional arrays can also be declared by attaching further indices during variable definition,
which have to be separated by commas,:
Dim x(3,4) As Integer
Dim y(2,2,2) As Integer
Arrays may in BASIC have up to 16 indices (dimensions). The maximum value for an index is
65535. The indices of arrays are in any case zero based, i .e. each index will start with a 0.
During program execution there will be no verification whether or not the defined index limits of an
array have been exceeded. If an index becomes too large during program execution the access to
alien variables will be tried which in turn may create a good chance for a program breakdown.
Strings
There is no explicit "String" data type. A string is based on an array of data type Char. The size of
the array must be chosen in such a way that all characters of the string fit into the character array.
Additionally some space is needed for a terminating character (decimal Zero) inorder to indicate the
end of the character string.
Example for a character string with a 20 character maximum:
Dim str1(21) As Char
As an exception Char arrays may have character strings assigned to. Here the character string is
placed between quotation marks.
str1="hallo world!"
Strings cannot be assigned to multi dimensional Char arrays. There are however tricks for
advanced users:
Dim str_array(3,40) As Char
Dim Single_str(40) As Char
Single_str="A String"
Str_StrCopy(str_array,Single_str,40)
This will work because with a gap of 40 characters after the first string there will in str_array be room
for the second string.
© 2008 Conrad Electronic
, the third by
, ... up to
x[1]
x[2]
' array with 3*4 entries
' array with 2*2*2 entries
. When defining of course other index
x[9]
// will copy Single_str in the second string
Compiler
112
Need help?
Do you have a question about the C-Control Pro Mega Series and is the answer not in the manual?
Questions and answers