ARRAYS OF RECORDS
can also be created, in the same way as arrays of any of the four
basic data types. The following statement declares a record
called date.
type date = record month, day, year : integer end;
Lets now create an array of these records, called birthdays.
var birthdays : array[1..10] of date;
This creates an array of 10 elements. Each element consists of a record of type date, ie, each element consists of three integers, called month, day and year.
Pictorially it looks like,
|----------------| | month | <----<---------------- |----------------| | | | day | |--Element 1 | |----------------| | | | year | <---- | |----------------| | | month | <---- | |----------------| | | | day | |--Element 2 | |----------------| | |--< birthdays | year | <---- | |----------------| | | |----------------| | | month | <---- | |----------------| | | | day | |--Element 10 | |----------------| | | | year | <----<---------------- |----------------|
Consider the following assignment statements.
birthdays[1].month := 2; birthdays[1].day := 12; birthdays[1].year := 1983; birthdays[1].year := birthdays[2].year;
which assign various values to the array elements.