FIND¶
Searches for a substring within a string.
Signature¶
┌─────────┐
IN1 ─┤ │
│ FIND ├─ OUT
IN2 ─┤ │
└─────────┘
FUNCTION FIND : ANY_INT
VAR_INPUT
IN1 : ANY_STRING;
IN2 : ANY_STRING;
END_VAR
END_FUNCTION
Returns INT. FIND accepts STRING for IN1 and IN2. Both
inputs must share the same type.
Inputs
Name |
Type |
Description |
|---|---|---|
|
|
The string to search within. |
|
|
The substring to find. |
Outputs
Name |
Type |
Description |
|---|---|---|
Return value |
|
1-based position of the first occurrence of IN2 in IN1, or 0 if not found. |
Description¶
FIND(IN1, IN2) returns the position of the first occurrence of
IN2 within IN1. Positions are 1-based. If IN2 is not found,
the function returns 0.
Example¶
result := FIND('Hello World', 'World'); (* result = 7 *)
result := FIND('Hello World', 'xyz'); (* result = 0 *)
result := FIND('ABCABC', 'BC'); (* result = 2 *)
See Also¶
References¶
IEC 61131-3 §2.5.1.5.7