REPLACE
Function Name |
REPLACE |
---|---|
Description |
Outputs a specific number of characters taken from a string input. The characters are taken from a specified position in the input string. |
Arguments |
IN1 {STRING} The IN1 input is a string input. The REPLACE function uses characters from the IN1 input for its output: it replaces characters from the IN1 input with characters from the IN2 input. IN2 {STRING} The IN2 input is a string input. The REPLACE function uses characters from the IN2 input for its output: it replaces characters from the IN1 input with characters from the IN2 input. L {INT} Defines the number of characters in the IN1 input that are to be replaced by the characters in the IN2 input. P {INT} Defines the starting point for the replacement, that is, the position in the IN1 string where the IN2 characters will be 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 IN1 string with a specified number of its characters replaced by the characters in the IN2 string. |
Example:
Function Block Diagram - REPLACE:
In this example, the IN1 input is 'PIPELINE ALARM', IN2 is 'STATUS', L is 6 and P is 10. This means that the REPLACE function will take the IN1 input, remove 6 characters from character 10 onwards and replace them with 'STATUS'. This provides an output of 'PIPELINE STATUS'.
ST Program - REPLACE:
To use a REPLACE function in an ST program, you need to use this syntax:
- Output := REPLACE ('IN1','IN2', L, P);
Where Output, IN1, IN2, L and P are defined as variables earlier in the ST program.
Alternatively, you can use the following syntax:
- Output := REPLACE (IN1:= 'PIPELINE ALARM', IN2:= 'STATUS' L:= 6, P:=10);
Where the 'PIPELINE ALARM', 'STATUS', 6 and 10 values are the input values (in this case, they are the same values as used in the Function Block Diagram example above).