INSERT
Function Name |
INSERT |
---|---|
Description |
Inserts one string into another string at a specified position, then outputs the result. |
Arguments |
IN1 {STRING} The IN1 string is the string that is used as the basis for the output. The IN2 string is inserted into the string provided by the IN1 input. IN2 {STRING} The string that is inserted into the string provided by IN1. P {INT} Defines the insertion point in the IN1 string into which the IN2 string is inserted. As with the other string position numbers, 1 is the first character in the string, 2 is the second, 3 is the third and so on. For more information on the data types for the inputs and outputs, see Data Type Hierarchy. |
Returns |
Output {STRING} The output is a string that is the result of the IN2 string being inserted into the IN1 string at the position defined by P. |
Example:
Function Block Diagram - INSERT:
In this example, IN1 is 'ALARM', IN2 is 'OVERRIDDEN', and P is 6. The INSERT function takes the 'ALARM' string and inserts the 'OVERRIDDEN' string into it at character 6. It then outputs the resulting string which is ALARMOVERRIDDEN. In this case, the IN2 string has been inserted at the end of the string by defining P as the number after the last character in the IN1 string. If P had been set to 4, the output would have been 'ALAROVERRIDDENM'.
ST Program - INSERT:
To use an INSERT function in an ST program, you need to use this syntax:
- Output := INSERT ('Input 1', 'Input 2', P);
Where Output, Input 1, Input 2, and P are defined as variables earlier in the ST program.
Alternatively, you can use the following syntax:
- Output := INSERT (IN1:= 'ALARM', IN2:= 'OVERRIDDEN', P:= 6);
Where the 'ALARM', 'OVERRIDDEN', and 6 values are the input values (in this case, they are the same values as used in the Function Block Diagram example above).