User manual
mikroPascal PRO for dsPIC30/33 and PIC24
MikroElektronika
212
Note: In mikroPascal PRO for dsPIC30/33 and PIC24, you cannot use the record construction directly in variable
declarations, i.e. without type.
For example, the following declaration creates a record type called Dot:
type
TDot = record
x, y : real;
end;
Each Dot contains two elds: x and y coordinates. Memory is allocated when you instantiate the structure, like this:
var m, n: TDot;
This variable declaration creates two instances of Dot, called m and n.
A eld can be of the previously dened record type. For example:
// Structure dening a circle:
type
TCircle = record
radius : real;
center : TDot;
end;
Accessing Fields
You can access the elds of a record by means of dot (.) as a direct eld selector. If we have declared variables
circle1 and circle2 of previously dened type TCircle:
var circle1, circle2 : TCircle;
we could access their individual members like this:
circle1.radius := 3.7;
circle1.center.x := 0;
circle1.center.y := 0;
Accessing the elds is possible via the with statement as well.
You can also commit assignments between complex variables, if they are of the same type:
circle2 := circle1; // This will copy values of all elds