Setting Variables Initial Value
Using the Init value field of the variables editor, you can set a valid initial value to the selected variable. You can directly enter the desired value within the text area (which is the fastest way) or you can click the button in the corresponding cell and use the editor that pops up to enter your value (this solution is useful if you are valorizing complex data type).
Base data typesFor base data types you can just enter a valid value, which respects the range of values for that data type.StringWhen selecting the type string, you’ll see also the field array is valorized with [32]; that is the number of character allowed inside the variables, exceeding character will be truncated.To initialize a sting, just enter the desired character within single quotes.The string terminator character will be added automatically, so you don’t need to insert it; also the string terminator is not counted within the specified size: that means that if the specified size is 32, you can enter 32 chars and the terminator will be the 33th, the string length will be 33.The single quotes are not counted among the other characters, they are ignored.
WStringWhen selecting the type wstring, you’ll see also the field array is valorized with [32]; that is the number of wide character allowed inside the variables, exceeding character will be truncated.To initialize a wsting, just enter the desired character within double quotes.The string terminator character will be added automatically, so you don’t need to insert it; also the string terminator is not counted within the specified size: that means that if the specified size is 32, you can enter 32 wide chars and the terminator will be the 33th, the wstring length will be 66.The double quotes are not counted among the other characters, they are ignored.
ArrayBefore inserting the initial values, you must specify that the desired variable is an array; to do so, click the button inside the Array field, and use the pop up dialog to specify the array size.
Now you can enter the initial values: for the array, write the values within square brackets and separate each value with a comma.
Multidimensional arrays (MATRIXES)As per the array, you must first specify the matrix size; so open the array editor and enter more than one dimension.
Now you can enter the initial values: for the matrix, write the values within square brack- ets and separate each value with a comma. Write all the value inline, the indexes will be automatically applied.
StructuresStructures are user defined data types, so the first thing to do is create a structure.Let’s suppose we have a structure like the following one:
The initial value of a structure is written within round brackets, each field is separated with a comma, and you must also specify the field you are valorizing since you are not required to valorize every field of the structure nor you’re required to respect the order of the fields.
Array of structuresAn array can be of different types, even of complex data types; to make an example, let’s suppose we have an array of structures, where the structure has these fields:
To initialize the array we will write the values within square brackets, each value will be separated with a comma, and every value will be the initial value of a structure; the result will be something like this:
Function BlockA function block is initialized the same way of a structure, you can initialize all types of variables of the function block (local vars, input vars, output vars…).Let’s suppose we have a function block with the following fields:
The initial value of a function block is written within round brackets, each field is sepa- rated with a comma, and you must also specify the field you are valorizing since you are not required to valorize every field of the function block nor you’re required to respect the order of the fields.