BASIC Moves Development Studio
06/2005
Danaher Motion
18 Rev
E
M-SS-005-03l
2.2.4.1. S
TRUCTURES
A structure is a new data type used for storing a list of variables of different
type in one variable.
2.2.4.1.1 Definition
Since a structure is a user-defined data type; it must first be defined.
Structure type definition can be done only in the Config.prg file (before the
PROGRAM
block, at the declaration level), using the following syntax:
TYPE <
structure_type_name
>
<
element_name
>{[]} AS <
element_type
> {OF <
robot_type
>}
…
END TYPE
This block defines the name of the structure type and the names, types and
array sizes of the various structure elements (fields). Data types supported
as structure elements are: long, double, string, and points (JOINT and
LOCATION). Array elements can only have a single dimension. The
maximum structure block can include: 100 longs, 100 doubles, 100 strings,
100 points JOINTs and/or LOCATIONs), 10 long-type arrays, 10 double-type
arrays, 4 string-type arrays and 2 point-type arrays JOINTs and/or
LOCATIONs). The total size of the MC-Basic structure is limited. The
maximum number of each type of element is fixed. Trying to define more
structure elements than allowed results in a translation error. An array of
structures may have up to 10 dimensions.
2.2.4.1.2 Declare
You must declare a structure before you can use it. If you want to declare a
structure variable, you must first declare a structure data type and then use
this data type structure to declare the variable. The structure data type
definition can be done in the Config.prg file only with the following syntax
(before the
PROGRAM
token, at the declaration level):
TYPE <
variable_name
>
<
variable_name
> as <
type
>
<
variable_name
> as <
type
> {<
of
> <
robot_type
>}
…
END TYPE
This block defines the new element names of the structure type. The
different types supported for the structure are: long, double, string, and
points. The maximum structure block is defined as:
100 longs
100 doubles
100 strings
100 points
2.2.4.1.3 Syntax
(COMMON SHARED|DIM {SHARED}) <
variable_name
> AS <
variable_name
>
or
(COMMON SHARED|DIM {SHARED}) <
variable_name
>[<
index
>] AS
<
variable_name
>(arrays of structure)
where the second variable name = the structure type