FIND

FIND 1:

FIND searches for a partial string within a 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.

FUNCTION FIND :INT

VAR_INPUT
    STR1    :STRING(255);
    STR2    :STRING(255);
END_VAR

Example in IL:

LD 'SUXYSI'

FIND 'XY'

ST Var1 (* Result is 3 *)

Example in ST:

Var1 := FIND
('SUXYSI','XY');

Requirements

Development environment

Target system type

PLC libraries to include

TwinCAT Version >= 2.6.0

PC or CX (x86)

Standard.Lib

TwinCAT Version >= 2.6.0

BC (165)

Standard.Lb6

TwinCAT Version >= 2.9.0

BCxx50 or BX

Standard.lbx

TwinCAT Version >= 2.10.0 Build >= 1301

CX (ARM)

Standard.lib