Standard Library Elements |
• 319 |
String functions |
|
|
|
Example in FBD:
Example in ST:
VarSTRING1 := LEFT ('SUSI',3);
Note:
String functions are not "thread safe"!
Right returns the right, initial string for a given string.
RIGHT (STR, SIZE) means: Take the first SIZE character from the right in the string STR.
Input STR is of type STRING, SIZE is of type INT, the return value of the function is of type STRING.
Example in IL:
LD |
'SUSI' |
RIGHT 3 |
|
ST |
VarSTRING1 (* Ergebnis ist 'USI' *) |
Example in FBD:
Example in ST:
VarSTRING1 := RIGHT ('SUSI',3);
Note:
String functions are not "thread safe"!
13.1.4MID
Mid returns a partial string from within a string.
WAGO-I/O-SYSTEM 759 WAGO-I/O-PRO 32
320 • Standard Library Elements
String functions
Input STR is type STRING, LEN and POS are type INT, the return value of the function is type STRING.
MID (STR, LEN, POS) means: Retrieve LEN characters from the STR string beginning with the character at position POS.
Example in IL:
LD |
'SUSI' |
RIGHT 2,2 |
|
ST |
VarSTRING1 (* Ergebnis ist 'US' *) |
Example in FBD:
Example in ST:
VarSTRING1 := MID ('SUSI',2,2);
Note:
String functions are not "thread safe"!
13.1.5CONCAT
Concatenation (combination) of two strings.
The input variables STR1 and STR2 as well as the return value of the function are type STRING.
Example in IL:
LD |
'SUSI' |
|
CONCAT |
'WILLI' |
|
ST |
VarSTRING1 (* Ergebnis ist 'SUSIWILLI' *) |
|
Example in FBD:
Example in ST:
VarSTRING1 := CONCAT ('SUSI','WILLI');
WAGO-I/O-SYSTEM 759 WAGO-I/O-PRO 32
Standard Library Elements |
• 321 |
String functions |
|
|
|
Note:
String functions are not "thread safe"!
13.1.6INSERT
INSERT inserts a string into another string at a defined point.
The input variables STR1 and STR2 are type STRING, POS is type INT and the return value of the function is type STRING.
INSERT(STR1, STR2, POS) means: insert STR2 into STR1 after position POS.
Example in IL:
LD |
'SUSI' |
|
INSERT |
'XY',2 |
|
ST |
VarSTRING1 (* Ergebnis ist 'SUXYSI' *) |
|
Example in FBD:
Example in ST:
VarSTRING1 := INSERT ('SUSI','XY',2);
Note:
String functions are not "thread safe"!
DELETE removes a partial string from a larger string at a defined position.
The input variable STR is type STRING, LEN and POS are type INT, the return value of the function is type STRING.
DELETE(STR, L, P) means: Delete L characters from STR beginning with the character in the P position.
Example in IL:
LD 'SUXYSI'
DELETE 2,23
ST |
Var1 (* Ergebnis ist 'SUSI' *) |
WAGO-I/O-SYSTEM 759 WAGO-I/O-PRO 32
322 • Standard Library Elements
String functions
Example in FBD:
Example in ST:
Var1 := DELETE ('SUXYSI',2,3);
Note:
String functions are not "thread safe"!
13.1.8REPLACE
REPLACE replaces a partial string from a larger string with a third string.
The input variable STR1 and STR2 are type STRING, LEN and POS are type INT, the return value of the function is type STRING.
REPLACE(STR1, STR2, L, P) means: Replace L characters from STR1 with STR2 beginning with the character in the P position.
Example in IL:
LD |
'SUXYSI' |
|
REPLACE |
'K',2,2 |
|
ST |
VarSTRING1 (* Ergebnis ist 'SKYSI' *) |
|
Example in FBD:
Example in ST:
VarSTRING1 := REPLACE ('SUXYSI','K',2,2);
Note:
String functions are not "thread safe"!
FIND searches for a partial string within a string.
WAGO-I/O-SYSTEM 759 WAGO-I/O-PRO 32