24.01.2015 Views

PLC Programming

  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Appendix D: CoDeSys Libraries<br />

LD<br />

CONCAT<br />

'SUSI'<br />

'WILLI'<br />

ST VarSTRING1 (* Ergebnis ist 'SUSIWILLI' *)<br />

Example in FBD:<br />

Example in ST:<br />

VarSTRING1 := CONCAT ('SUSI','WILLI');<br />

Please Note: The CONCAT function does not work, if nested over more than five levels.<br />

Please Note: String functions are not "thread safe": When using tasks, string functions may only be used in a<br />

single task. If the same function is used in different tasks, there is a danger of overwriting.<br />

INSERT<br />

INSERT inserts a string into another string at a defined point.<br />

The input variables STR1 and STR2 are type STRING, POS is type INT and the return value of the<br />

function is type STRING.<br />

INSERT(STR1, STR2, POS) means: insert STR2 into STR1 after position POS.<br />

Example in IL:<br />

LD<br />

INSERT<br />

'SUSI'<br />

'XY',2<br />

ST VarSTRING1 (* Ergebnis ist 'SUXYSI' *)<br />

Example in FBD:<br />

Example in ST:<br />

VarSTRING1 := INSERT ('SUSI','XY',2);<br />

Please Note: String functions are not "thread safe": When using tasks, string functions may only be used in a<br />

single task. If the same function is used in different tasks, there is a danger of overwriting.<br />

DELETE<br />

DELETE removes a partial string from a larger string at a defined position.<br />

The input variable STR is type STRING, LEN and POS are type INT, the return value of the function is<br />

type STRING.<br />

DELETE(S TR, L, P) means: Delete L characters from STR beginning with the character in the P<br />

position.<br />

Example in IL:<br />

LD<br />

DELETE 2,23<br />

'SUXYSI'<br />

ST Var1 (* Ergebnis ist 'SUSI' *)<br />

CoDeSys V2.3 10-41

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!