Documentation

REPLACE

Function name

REPLACE

ST call

PROGRAM REPLACE_DEMO
VAR
IN1,IN2,OUT1: STRING;
L1, P1: INT;
END_VAR
OUT1:=REPLACE(IN1:=IN1,IN2:=IN2,L:=L1,P:=P1);
END_PROGRAM

Description

The REPLACE function replaces part of the input string in1 by another string, in2. The starting position "p" must be greater than 0 and less than the total number of characters in the string in1. If the replaced part is out of the input string, it is a input parameter error. If the "l" and "p" values are entered falsely, there is an exception and the PLC stops. If stop on exception is disabled, the function output gives the last correct value.

Inputs

Input Type Description
IN1 ANY_STRING Input string, of which a part will be replaced
IN2 ANY_STRING Input string which will replace the omitted part
L ANY_INT Length of the deleted part
P ANY_INT Position where the deleted part starts, if at the first character, p=1

Outputs

Output Type Description
=> ANY_STRING Output string

Example