Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
19
Добавлен:
11.10.2020
Размер:
3.39 Mб
Скачать

318 Standard Library Elements

String functions

13Standard Library Elements

13.1 String functions

Note:

String functions are not "thread safe": When using tasks, string functions may only be used in a single task. If the same function is used in different tasks, there is a danger of overwriting.

13.1.1LEN

Returns the length of a string. Input STR is of type STRING, the return value of the function is type INT.

Example in IL:

LD 'SUSI'

LEN

ST

VarINT1

(* Ergebnis ist 4 *)

Example in FBD:

Example in ST:

VarSTRING1 := LEN ('SUSI');

Note:

String functions are not "thread safe"

13.1.2LEFT

Left returns the left, initial string for a given string. Input STR is type

STRING, SIZE is of type INT, the return value of the function is type

STRING.

LEFT (STR, SIZE) means: Take the first SIZE character from the right in the string STR.

Example in IL:

LD 'SUSI'

LEFT 3

ST

VarSTRING1 (* Ergebnis ist 'SUS' *)

WAGO-I/O-SYSTEM 759 WAGO-I/O-PRO 32

Standard Library Elements

319

String functions

 

 

 

Example in FBD:

Example in ST:

VarSTRING1 := LEFT ('SUSI',3);

Note:

String functions are not "thread safe"!

13.1.3RIGHT

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"!

13.1.7DELETE

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