FIND - Find an occurrence of a string or character in another string

Help Contents

Introduction

Returns the location of the first occurrence a string or character in another string.

Syntax

Informal Syntax:

FIND( In1, In2 )

Formal Syntax:

FIND( In1:=expression, In1:=expression )

Parameters

ParameterTypeDescription
In1ANY_STRINGThe string to search.
In2ANY_CHARSThe string or character to find.

The function is overloaded and accepts a range of types for the In1 and In2 parameters:

Return Value

The function FIND returns the character offset of the first occurrence of In2 in string In1.

If the string In2 is found in In1, the return value is a 1-based character offset. For example, if In2 is found at the start of In1, the return value is 1.

If string In2 is not found in string In1, the function returns 0 (zero). If the parameter In2 is an empty string, the function returns 0 (zero).

Examples

ExampleReturn Value
FIND('condition', 'c')UINT#1
FIND('condition', 'o')UINT#2
FIND("Something else", "Some Text")UINT#0
FIND('FINS', '')UINT#0

Standards Compliance

IEC 61131-3 Second Edition: Table 29.9.

IEC 61131-3 Third Edition: Table 34.9.

Note: The function allows different string types as parameters. The IEC 61131-3 Third Edition standard states this should be an error.

Further Information

String Functions

To learn about other String Functions.

Common Elements

To learn about other IEC 61131-3 Common Elements.

Glossary

For the meaning of terms used in Fernhill SCADA.