meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

automation:topics:array [2025/12/09 16:17] – created vamsanautomation:topics:array [2025/12/09 16:32] (current) vamsan
Line 5: Line 5:
  
 {{:automation:topics:dim1_en.png|2 dimensional array}} {{:automation:topics:dim1_en.png|2 dimensional array}}
 +
 +The image above displays a two-dimensional array of type "byte." The first index represents the rows, while the second represents the columns. The value range of a byte is 0 to 255, so only values within this range are allowed. In the example above, the program's type definition is as follows:
 +
 +<code>
 +arry : Array[0..5, 0..2] of Byte;
 +</code>
 +
 +The assignment is displayed in the code like this:
 +
 +<code>
 +tomb[3, 1] := 1;
 +</code>
 +
 +The indexing of a three-dimensional array can be illustrated as follows:
 +
 +{{:automation:topics:dim2_en.png|3 dimensional array}}
 +
 +In this case, the above assignment can be defined in the program as follows:
 +
 +<code>
 +tomb[3, 1, 0] := 1;
 +</code>
 +
 +The elements of the array are always homogeneous, meaning their types cannot vary. However, there can be multiple instances of a single type within a single array if we define a Struct type as an array element. The hydraulic motors described as an example in [[structure|Struct]] can also be defined as an array:
 +
 +{{:automation:topics:dim3_en.png|array & structure}}
 +
 +In this case, I specified the type of the four-element array as "Struct". Here, a field opens under the name of the first array element (tomb[0]), where the Struct's elements can be defined. It is important that the array is homogeneous, meaning the structure can only be set for the first element; the other elements will be copies of it without the ability to modify the structure (values, of course, can change). In the example above, the value assignment will look like this (the DB name is //“motors”//):
 +
 +<code>
 +"motors".tomb[1].current := 32.2;
 +</code>
 +
 +
 +
 +