FIND

Provided by standard.lib.

FIND searches for a partial string within a string.

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

FIND(STR1, STR2) means: Find the position of the first character where STR2 appears in STR1 for the first time. If STR2 is not found in STR1, then OUT:=0.

Example in IL

LD   ‘abcdef’

FIND ‘de’

ST   VarINT1 (* Result is ‘4’ *)

Example in FBD

../_images/114e0a7843757ea50a33139006eab46b

Example in ST

arINT1 := FIND (‘abcdef’,’de’);

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