9.1 RECORD Statement
The RECORD statement names and defines a data struc-
ture. Once a data structure (or RECORD) has been named
and defined, you can use that RECORD name anywhere that
you can use a BASIC data type keyword. You build the data
structure using:
.
Variables of any valid BASIC data type
.
RECORD variables of previously defined RECORD data
types
.
Any combination of the two
The following example creates a RECORD called employee .
employee is a data structure that contains on LONG integer,
one 10-character string, one 20-character string, and one
11-character string.
RECORD Employee
LONG Emp_number
STRING First_name = 10
STRING Last_name = 20
STRING Soc_sec_number = 11
END RECORD Empolyee
To create instances of this data structure, you use declarative
statements. In the following example, the first DECLARE
statement creates a variable called Emp_rec of data type
Employee . The second DECLARE statement creates a one-
dimensional array called Emp_array that contains 1001
instances of the Employee data type.
DECLARE Employee Emp_rec
DECLARE Employee Emp_array (1000)
Any reference to a RECORD component must contain the
name of the RECORD instance (that is, the name of the de-
clared variable) and the name of the elementary RECORD
component you are accessing, separated by two colons (::).
For example, the following program assigns values to an
instance of the Employee RECORD template:
EXAMPLE: Click to display example.
When you access an array of RECORD instances, the ar-
ray subscript should immediately follow the name of the
RECORD variable. The following example shows an array of
RECORD instances:
EXAMPLE: Click to display example.
You can have a RECORD that contains an array. When you
declare arrays, BASIC allows you to specify both lower and
upper bounds.
EXAMPLE: Click to display example.
Because any reference to a component of a RECORD in-
stance must begin with the name of the RECORD instance,
RECORD component names need not be unique in your
program. For example, you can have a RECORD compo-
nent called First_name in any number of different RECORD
statements. References to this component are unambiguous
because every RECORD component reference must specify
the record instance in which it resides.