When you store information on your computer, where is it stored? A file? A folder? Well that file uses a data structure to store your information, and this data structure is called a Record.
Generally, all of the files we use consist of records. These records are made up of a number of fields, with each field holding one item of the data, pertaining to that record. For example, for a file holding staff records you might have the fillowing structure:
ID Name Role
0 Miss S Teacher
1 Mr R Teacher
Each record has a record type, which states the different elements a record would need, and would be used to allow a variable to be declared as that type. For the staff example above, we could call the record type staffType (note the name should reflect what the record will store). It would be declared as follows:
staffType = record:
integer ID
string Name
String Role
end record
It is as simple as that! When declaring a variable of a record type, it is key to remember that like the record type names, the variable names should reflect the record type that it will be. To declare a variable of type staffType, called staff, we would do the following:
staff: staffType
Food for Thought
If we refer to the name of the staff member as staff.name, how would we refer to the staff member's role?
Comentarios