Declaration of reference variables (incl. assignments to them)
Syntax |
---|
|
Meaning | |
---|---|
Declaration of one or more →reference variables, As Use the optional →initial value
|
The declaration of reference variables is possible within these sections:
(Consult the respective description of the section about possibly additional possibilities for the variable.)
Section |
The declaration of the reference is done as: |
---|---|
|
internal variable (see "Declaration of internal variables in ST") |
|
input variable (see "Declaration of input variables in ST") |
|
output variable (see "Declaration of output variables in ST") |
|
temporary variable (see "Declaration of temporary variables in ST") |
Example |
---|
|
Assignments to reference variables
In general, →assignments to reference variables are possible within the declared language element. However, the usage of REF(...)
is restricted (see the above restrictions).
Syntax |
---|
|
The expression on the right side of the assignment operator ":=
" may be one of the following constructs:
-
REF(name)
,name
must be a variable of the same data type as the reference variable to which the assignment is done – Mind the restrictions for the usage ofREF()
that are listed above. -
NULL
-
another declared reference variable, if it is of the same data type as the reference variable to which the assignment is done
If the assignment is done to anARRAY
reference variable, the variable must be based on the same data type and the same index subrange.
Example |
---|
|
Dereferencing: Accessing the content of reference variables
Accessing the content of reference variables is known as dereferencing. This is done by the character ^
that follows the name of the reference variable.
Examples |
---|
|
Access to reference variables with the content NULL Neuron Power Engineer does not validate these ST-constructs when entered in the ST-editor but when the application is executed. In this case, the following error handling occurs:
In the above example, the assignment Neuron recommends you to add code to your application (e.g. |