Mikroelektronika MIKROE-742 데이터 시트
Records
A record (analogous to a structure in some languages) represents a heterogeneous
set of elements. Each element is called a field. The declaration of the record type
specifies a name and type for each field. The syntax of a record type declaration is
set of elements. Each element is called a field. The declaration of the record type
specifies a name and type for each field. The syntax of a record type declaration is
type recordTypeName = record
fieldList1 : type1;
...
fieldListn : typen;
...
fieldListn : typen;
end;
where
recordTypeName
is a valid identifier, each
type
denotes a type, and each
fieldList
is a valid identifier or a comma-delimited list of identifiers. The scope of
a field identifier is limited to the record in which it occurs, so you don’t have to worry
about naming conflicts between field identifiers and other variables.
about naming conflicts between field identifiers and other variables.
Note: In mikroPascal PRO for AVR, you cannot use the
record
construction direct-
ly in variable declarations, i.e. without
type
.
For example, the following declaration creates a record type called
TDot
:
type
TDot =
record
x, y : real;
end;
Each
TDot
contains two fields: x and y coordinates. Memory is allocated when you
declare the record, like this:
var m, n: TDot;
This variable declaration creates two instances of TDot, called
m
and
n
.
A field can be of previously defined record type. For example:
// Structure defining a circle:
type
type
TCircle =
record
radius : real;
center : TDot;
center : TDot;
end;
151
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroPASCAL PRO for AVR
CHAPTER 5