CONCAT

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.

Parameters

Input

Unnamed input (STRING)

beginning input string

Unnamed input (STRING)

string that will be attached to the beginning string

Output

Unnamed output (STRING)

The number of input contacts is expandable, see also modifying elements.

Remarks

  • 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.

Error flags

sys_bIsOperationErrorHold (turns to TRUE and remains TRUE)

if a string applied at the input or output is an invalid string

sys_bIsOperationErrorNonHold (turns to TRUE for one scan)

if a string applied at the input or output is an invalid string

sys_bIsCarry (turns to TRUE for one scan)

if the output string is longer than the length defined for the output variable in the field "Type"

Example

POU header

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.

POU body

sString3 is attached to sString2 and this string is attached to sString1. The resulting string is written into sResultString.

LD body

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

ST body

sResultString:=CONCAT(sString1, sString2, sString3);

IL body

Modified on: 2022-03-02Feedback on this pagePanasonic hotline