User manual

mikroBasic PRO for PIC32
MikroElektronika
211
For example, the following declaration creates a structure type called Dot:
structure Dot
dim x as oat
dim y as oat
end structure
Each Dot contains two members: x and y coordinates; memory is allocated when you instantiate the structure, like
this:
dim m, n as Dot
This variable declaration creates two instances of Dot, called m and n.
A member can be of the previously dened structure type. For example:
Structure dening a circle:
structure Circle
dim radius as oat
dim center as Dot
end structure
Structure Member Access
You can access the members of a structure by means of dot (.) as a direct member selector. If we had declared the
variables circle1 and circle2 of the previously dened type Circle:
dim circle1, circle2 as Circle
we could access their individual members like this:
circle1.radius = 3.7
circle1.center.x = 0
circle1.center.y = 0
You can also commit assignments between complex variables, if they are of the same type:
circle2 = circle1 ‘ This will copy values of all members