Learn PLCs free
String OperationsIntermediateIEC 61131-3

FIND (String Search)

Finds position of a substring within a string; returns 0 if not found.

The FIND function searches for the first occurrence of a substring within a source string and returns the starting position (1-based index). If the substring is not found, it returns 0. FIND is essential for parsing variable-format data, searching for delimiters in communication strings, and validating string content in PLC programs.

Parameters

Inputs

NameTypeDescription
IN1STRINGSource string to search in
IN2STRINGSubstring to search for

Outputs

NameTypeDescription
OUTINTPosition of first occurrence (1-based), 0 if not found

Structured Text Example

// Find delimiter position
Comma_Pos := FIND(IN1 := CSV_Line, IN2 := ',');

IF Comma_Pos > 0 THEN
    First_Field := LEFT(IN := CSV_Line, L := Comma_Pos - 1);
END_IF;

// Check if string contains error
Has_Error := FIND(IN1 := Response, IN2 := 'ERR') > 0;

20 Production-Ready Ladder Logic Templates

Stop writing the same rungs from scratch. Get copy-paste-ready templates for motor control, PID loops, safety interlocks, conveyors, and more.

Platform-Specific Implementation

S

Siemens (TIA Portal)

Use FIND instruction in TIA Portal. Case-sensitive search.

AB

Allen-Bradley (Studio 5000)

Use FIND instruction in Studio 5000.

C

CODESYS

Use FIND() function in ST.

Common Applications

  • Delimiter-based string parsing
  • Substring validation
  • Protocol response parsing
  • Barcode data extraction
  • Error string detection

Frequently Asked Questions

What is FIND (String Search) in PLC programming?

Finds position of a substring within a string; returns 0 if not found. The FIND function searches for the first occurrence of a substring within a source string and returns the starting position (1-based index). If the substring is not found, it returns 0.

What are common applications of FIND (String Search)?

FIND (String Search) is commonly used for: Delimiter-based string parsing, Substring validation, Protocol response parsing, Barcode data extraction, Error string detection.

How do I use FIND (String Search) in different PLC platforms?

Siemens: Use FIND instruction in TIA Portal. Case-sensitive search. Allen-Bradley: Use FIND instruction in Studio 5000. CODESYS: Use FIND() function in ST.

Stop Writing Ladder Logic From Scratch

Get 20 production-ready ladder logic templates for $29 -- download instantly and use them on your next project today.

20
Ready-Made Templates
LD + ST
Both Languages Included
$29
One-Time Purchase
Get Instant Access -- $29

Instant download - 30-day money-back guarantee - Use on unlimited projects

Free PLC simulator

Wire this block up and run it

Drop the instruction into a rung, hit Run, and watch it execute in your browser. 12 guided lessons across 8 PLC dialects — free account, no credit card.

Practice PLCs free →