INSERT block
Short summary
Name |
|
→POU type |
|
Category |
|
Conform to →IEC-standard |
currently restricted
|
Graphical interface |
|
Available since |
version 1.31.0 (for Neuron Power Engineer) |
Functionality
The block inserts one string into another string and returns the newly created string.
At input IN1
, enter a string (= 1st string). At input IN2
, enter another string (= 2nd string). At input P
, enter the position within the 1st string. The 2nd string is inserted after this position (the inserting operations begins at P
+1).
Special cases (see under "Example for usage within ST-editor"):
-
In case of
P = 0
, the 2nd string value is inserted before the 1st string value. In this case, the outputENO
is set to valueTRUE
because the inserting operation begins at1
. -
If the value for
P
is > the length of the string value forIN1
, the block returns the 1st string, blanks up to and including positionP
and then the 2nd string. In this case, the outputENO
is set to valueFALSE
. -
If a negative value is connected to
P
, the block returns only the characters of the 1st string (i.e. the 2nd string is not inserted). In this case, the outputENO
is set to valueFALSE
as well.
Neuron Power Engineer determines the character positions within a string as follows: 1
, 2
, ..., n. 1
corresponds to the leftmost character position and n
to the length of the string.
Three-character combination of the dollar sign ($
) followed by two hexadecimal digits are evaluated as single character. Example: The string '$B15
' (corresponds to '±5
') consists of 2 characters. See →character string literal for more examples for those combinations.
Inputs, return value
|
Identifier |
Description |
|
---|---|---|---|
Inputs: |
|
|
1st input value (= string where to insert) |
|
|
2nd input value (= string to insert) |
|
|
|
position in the 1st input value after which to insert the 2nd input value |
|
Return value: |
– |
|
|
Input EN
and output ENO
are available when →calling the block. See "Execution control: EN, ENO" for information on input EN
and output ENO
.
See:
-
"Blocks for safe logic" whether this block is supported for developing safety-relevant applications.
-
"Highlighting safe logic in the FBD-editor" for the effects when using the block as a block for safe logic.
Internal error diagnostic for block
The block checks the would-be return value.
If the return value cannot be mapped in the available memory (the return value is too large), the output ENO
of the block is set to value FALSE
(or an equivalent). When you are using nested blocks with STRING
values, observe that the memory for STRING
values is restricted (see "In case of nested string blocks: How can the return value be entirely mapped ?" for details and examples).
The following special case might occur regarding this error case: If the result of the call is assigned to a variable that is used as input parameter for the call of this block as well (see the following example), the output ENO
of the embracing →POU is set to value FALSE
for this error case (but not the output ENO
of the called block). Example: ResultString := INSERT(IN1 := 'a', IN2 := ResultString, P := 1);
Moreover, the block checks the connected values whether a non-existent character position in a string is accessed. This is the case, if the value for P
is > the length of the string value for IN1
or a negative value is connected to P
. The output ENO
of the block is set to value FALSE
(or an equivalent) in both these cases.
Example for usage within ST-editor
|
When creating your application within the ST-editor, enter a call of a block by typing the text as requested by the syntax or use Content Assist.