5.2 User-defined Data Type
5.2.1 Array
- Maximum dimension of array, three dimensions
-
An example of a one-dimensional array is shown below:

-
An example of a two-dimensional array is shown below:

-
An example of a three-dimensional array is shown below:

-
Arrays of arrays (nested arrays) are not supported
-
When accessing array member variables, the array subscript can be a member variable of an integer array, but the nesting depth of the array subscript is allowed to be up to 9 levels.
- That is, the deepest allowed: A[X1[X2[X3[X4[X5[X6[X7[X8[n]]]]]]]]], where n, is an integer type, and X1 ~ X8 are integer array variables. Exceeding compilation error
-
When defining array variables, the ARRAY OF type and Baosky IDE type can only be supported basic data types, structure types and FB types without RETAIN members.
-
Array variables can only be set to RETAIN or NON RETAIN as a whole
-
Because arrays do not support nesting, when the variable is of STRING array type, the variable member is of STRING type and cannot directly access char.
Definition S1: ARRAY[0..10] of STRING; S1[n] is of STRING type. However, if S1: STRING is defined; S1[n] accesses char
- Currently, if users want to access the string members in the string array, they can only access the member char through split variable transition.
- StringArr: ARRAY[0..10] of STRING; Str1: STRING; C1: CHAR; m, n: INT;
- Supports the following operations Str1 := StringArr[n]; C1 := Str1[m];
5.2.2 Structure
- UDT is 4-byte aligned. When communicating with a third party, please pay attention to the data size issue to avoid data confusion.
- For example, when there are three member variables in UDT, namely DINT, DINT, and CHAR, the bytes occupied by UDT are 12Byte instead of 9Byte, as shown in the figure below

-
Structure, T3 have a maximum nesting depth of 6 levels. T4 has a maximum nesting depth of 8 levels. (ARRAY counts as one level)
-
IEC standard structure type does not support setting RETAIN for specific elements of the structure during definition. Structure variables can be set to RETAIN as a whole
-
The UDT structure type creation cannot be empty, otherwise a compilation error will be reported.
5.2.3 Structure array
The elements of the array can also be of structure type. Therefore, a structural array can be formed. Each element of the structure array is a subscripted structure variable with the same structure type. In practical applications, structure arrays are often used to represent a group with the same data structure. Such as a class's student files, a workshop employee's salary schedule, etc.
5.2.4 Function block type
-
After a function block FB is programmed, its function block name is a specific function block type.
-
The language elements of the function block type include the definition of data structures for input, output and internal variables. The function block type is similar to a special structure type from a pure data representation.
-
The difference between FB type and STRUCT type:
-
The STRUCT type is a pure data type, while the function block type is not a pure data type; the specific difference between the FB type and the STRUCT type is that when the FB instance of the function block type can be called, when the FB instance is called, it acts on the FB instance The FB program will be executed
-
Members of the STRUCT type cannot be individually set as RETAIN storage variables, while members of the FB type can be individually set as RETAIN.
-