menu prev next

RECORDS WITHIN RECORDS
Records can also contain other records as a field. Consider where both a date and time record are combined into a single record called date_time, eg,


	type  date = RECORD
	                day, month, year : integer
	             END;
	      time = RECORD
	                hours, minutes, seconds : integer
	             END;
	      date_time = RECORD
	                     sdate : date;
	                     stime : time
	                  END;

This defines a record whose elements consist of two other previously declared records. The statement

	var   today  : date_time;
declares a working variable called today, which has the same composition as the record date_time. The statements

	today.sdate.day     :=   11;
	today.sdate.month   :=    2;
	today.sdate.year    := 1985;
	today.stime.hours   :=    3;
	today.stime.minutes :=    3;
	today.stime.seconds :=   33;
sets the sdate element of the record today to the eleventh of february, 1985. The stime element of the record is initialised to three hours, three minutes, thirty-three seconds.


Copyright B Brown/P Henry/CIT, 1988-1997. All rights reserved.
menu prev next

1