Mikroelektronika MIKROE-742 데이터 시트

다운로드
페이지 532
ARRAYS
An array represents an indexed collection of elements of the same type (called the
base type). Because each element has a unique index, arrays, unlike sets, can
meaningfully contain the same value more than once.
Array Declaration
Array types are denoted by constructions in the following form:
array[index_start .. index_end] of type
Each of the elements of an array is numbered from 
index_start
through
index_end
. The specifier 
index_start
can be omitted along with dots, in which
case it defaults to zero.
Every element of an array is of 
type
and can be accessed by specifying array name
followed by element’s index within brackets.
Here are a few examples of array declaration:
var
weekdays : 
array[1..7] of byte;
samples  : 
array[50] of word;
begin
// Now we can access elements of array variables, for example:
samples[0] := 1;
if samples[37] = 0 then ...
Constant Arrays
Constant array is initialized by assigning it a comma-delimited sequence of values
within parentheses. For example:
// Declare a constant array which holds number of days in each month:
const
MONTHS : 
array[1..12] 
of
byte =
(31,28,31,30,31,30,31,31,30,31,30,31);
The number of assigned values must not exceed the specified length. The opposite
is possible, when the trailing “excess” elements are assigned zeroes.
For more information on arrays of 
char
, refer to Strings.
145
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroPASCAL PRO for AVR
CHAPTER 5