A composite variable contains different types of elements (members).
Remark: If you are handling custom variables, we advise you to declare:
- a composite variable if a single variable of this type is used in your project (to pass parameters to an API for example).
- a structure type if several variables of this type are used in different processes of the project.
ProductRef is composed of
SCode is int
PdtCode is fixed string on 10
ProductRef.SCode = 7
ProductRef.PdtCode = "Screen"
Declaring a composite variable Hide the details
<Variable name> is composed of
<Members of the composite variable>
Name of the composite variable to declare.
Declarations of the variables found in the composite variable. These variables are called members of the composite variable.
End of declaration of the composite variable.
Handling a member of a composite variable Hide the details
<Variable name>.<Member name>
Name of the structure variable to declare.
Name of the member to use.
Handling a composite variable
There is no need to reference the members of composite variable.
CompositeVar is composed of
Member1 is fixed string on 8
Member2 is fixed string on 12
Str = CompositeVar // Str is built by concatenating all the members
// of the composite variable
CompositeVar = Str // Str is transferred to the composite variable
Type of the members in a composite variable
The members of a composite variable can have the following types:
Any other type of data (composite variable, constant, ...) is forbidden.
Declaring an array member in a structure
- Declaring a member whose type is simple array:
The array dimensions are fixed when the array is declared. The array dimensions can be modified by Dimension
- Declaring a member whose type is dynamic array:
The array dimensions must be defined (which means that the array must be allocated) before using the array.
// Declare a composite variable
MyCompVar is composed of
x1 is int
x2 is dynamic array // Declare the array
// Allocate the array
MyCompVar.x2 = new dynamic array of 4,7 int
// Initialize the array
MyCompVar.x2[1,1] = 25
Limits of a composite variable
- assign a composite variable to another composite variable directly: each member must be assigned individually.
- compare two composite variables.
- pass a composite variable in parameter to a procedure.
- define an inheritance in a composite variable.
- restrict the access to a member of a composite variable: all members of a composite variable must be public.
Which "advanced" types can be a member?
An "advanced" variable can be a member of another "advanced" variable. The table below presents the different combinations:
Declaring variables with the same name
You cannot declare:
- two variables with the same name (regardless the type of these variables) in a process.
- two members with the same name in the same composite variable.