Records

A record consists of a number of fields

A field consists of a single data item and these may be of different types. For example a record may consist of three fields :

Field name Field type
Name String
Form String
ExamMark Integer

When used in programs, the name and type of each field will need to be declared.

 

     

Example 

In high level languages we need to set up a record type (PupilType) which defines the fields and field types...... and then declare a variable (Pupil)  to be of that type:

PupilType = record
  Name : string;
  Form : string;
  ExamMark : integer;
  end;
 
var Pupil : PupilType;

Values for each field can then be assigned...

Pupil.Name := 'Jimmy Nutten';
Pupil.Form := '12G'
Pupil.ExamMark := 85;

 

 

Sample A Level Question
(Click on answer box to reveal sample answer)

The sales department of a small company uses a computer system to store information about all its sales staff.
(a) One file contains the employee number, name, date of birth and address of each salesperson.
(i) Use this example to explain the difference between the two terms field and record.
(ii) What is the advantage of a record over an array?
(b) Outline an application in this system which might use:
(i) a two dimensional array;
(ii) a three dimensional array;