(,-
c
0'
The second example is really a modified combination of the three one-
dimensional arrays. The first column has been changed to the numeric
representation of the months because the names of the months
(character data) cannot be included in the same array with numeric
data.
It will be much easier to use the weather data if we keep it together in
three one-dimensional arrays, or in one two-dimensional array, than it
would be if we considered it as 36 separate variables. This chapter
will show you how to work with arrays in BASIC programs.
DEFINING AN ARRAY
When you want to work with an array, you must first tell the system
that you are using an array and not ordinary variables. This is called
defining your array. Defining the array merely involves telling the
system how big the array is going to be so the system can leave room
for it, and telling the system what kind of data will be in it. (Later on
you enter the data, but this is not part of defining the array.)
The data for your arrays can be numeric data or character data. You
can define an array to contain either kind of data, but it must contain
only one kind of data. You can't mix characters and numbers in a
single array. That's why we used the numbers of the months instead
of their names when we put the weather data in a two-dimensional
array.
An array composed of numbers is called an arithmetic array. It is
named by a single letter of the extended alphabet such as A or
T.
An array composed of character data is called a character array. It is
named by a single letter of the extended alphabet followed by a dollar
sign ($); for example, N$ or Q$.
To define either kind of array, you use a statement called DIM. In the
DIM statement, you name the array and include the size of it in
parentheses after the name.
DIM Statement for One-Dimensional Arrays
For a one-dimensional array, the size is a single number. Thus, to
define an arithmetic one-dimensional array A with 12 elements, your
DIM statement is:
0010 DIM A(12)
Arrays
95
(,-
c
0'
The second example is really a modified combination of the three one-
dimensional arrays. The first column has been changed to the numeric
representation of the months because the names of the months
(character data) cannot be included in the same array with numeric
data.
It will be much easier to use the weather data if we keep it together in
three one-dimensional arrays, or in one two-dimensional array, than it
would be if we considered it as 36 separate variables. This chapter
will show you how to work with arrays in BASIC programs.
DEFINING AN ARRAY
When you want to work with an array, you must first tell the system
that you are using an array and not ordinary variables. This is called
defining your array. Defining the array merely involves telling the
system how big the array is going to be so the system can leave room
for it, and telling the system what kind of data will be in it. (Later on
you enter the data, but this is not part of defining the array.)
The data for your arrays can be numeric data or character data. You
can define an array to contain either kind of data, but it must contain
only one kind of data. You can't mix characters and numbers in a
single array. That's why we used the numbers of the months instead
of their names when we put the weather data in a two-dimensional
array.
An array composed of numbers is called an arithmetic array. It is
named by a single letter of the extended alphabet such as A or
T.
An array composed of character data is called a character array. It is
named by a single letter of the extended alphabet followed by a dollar
sign ($); for example, N$ or Q$.
To define either kind of array, you use a statement called DIM. In the
DIM statement, you name the array and include the size of it in
parentheses after the name.
DIM Statement for One-Dimensional Arrays
For a one-dimensional array, the size is a single number. Thus, to
define an arithmetic one-dimensional array A with 12 elements, your
DIM statement is:
0010 DIM A(12)
Arrays
95