Concatenate (attach) a string
CONCAT concatenates (attaches) the second and the following input strings (IN1 + IN2 + ...) to the first input string and writes the resulting string into the output variable.
Input
beginning input string
string that will be attached to the beginning string
Output
The number of input contacts is expandable, see also modifying elements.
If this instruction is used with UTF-8 strings, please refer to the notes concerning UTF-8 strings under the data type STRING.
If the output string is longer than the length defined for the output variable in the field “Type”, only as many characters are copied as the output variable can hold.The system variable sys_bIsCarry is set.
if a string applied at the input or output is an invalid string
if a string applied at the input or output is an invalid string
if the output string is longer than the length defined for the output variable in the field "Type"
All input and output variables used for programming this function have been declared in the POU header. The same POU header is used for all programming languages.
VAR
sString1: STRING[32]:='A better ';
(*sample string 1*)
sString2: STRING[32]:='life. A ';
(*sample string 2*)
sString3: STRING[32]:='better world.';
(*sample string 3*)
sResultString: STRING[32]:='';
(*result: 'A better life. A better world.'*)
END_VAR
In this example the input variables (sString1, sString2 and sString3) have been declared. However, you may enter the strings directly into the function. The strings have to be put in inverted commas, both in the POU header and in the function.
sString3 is attached to sString2 and this string is attached to sString1. The resulting string is written into sResultString.
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 5 ;
NETWORK_BODY
B(B_VARIN,,sString1,14,1,16,3,);
B(B_VARIN,,sString2,14,2,16,4,);
B(B_VAROUT,,sResultString,22,1,24,3,);
B(B_F,CONCAT-3!,,16,1,22,5,,?D?D?D?C);
B(B_VARIN,,sString3,14,3,16,5,);
L(1,0,1,5);
END_NETWORK_BODY
END_NET_WORK
END_BODY
sResultString:=CONCAT(sString1, sString2, sString3);