24.01.2015 Views

PLC Programming

  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The Standard.lib library<br />

Example in FBD:<br />

REPLACE<br />

Example in ST:<br />

Var1 := DELETE ('SUXYSI',2,3);<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 />

REPLACE replaces a partial string from a larger string with a third string.<br />

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

the function is type STRING.<br />

REPLACE(STR1, STR2, L, P) means: Replace L characters from STR1 with STR2 beginning with the<br />

character in the P position.<br />

Example in IL:<br />

LD<br />

'SUXYSI'<br />

REPLACE 'K', 2,2<br />

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

Example in FBD:<br />

Example in ST:<br />

VarSTRING1 := REPLACE ('SUXYSI','K',2,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 />

FIND<br />

FIND searches for a partial string within a string.<br />

The input variable STR1 and STR2 are type STRING, the return value of the function is type STRING.<br />

FIND(STR1, STR2) means: Find the position of the first character where STR2 appears in STR1 for<br />

the first time. If STR2 is not found in STR1, then OUT:=0.<br />

Example in IL:<br />

LD<br />

FIND<br />

'SUXYSI'<br />

'XY'<br />

ST VarINT1 (* Ergebnis ist '3' *)<br />

10-42 CoDeSys V2.3

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

Saved successfully!

Ooh no, something went wrong!