FIND
Function Name |
FIND |
---|---|
Description |
The FIND function searches for a specific string in a string input. If it locates the specified string, it outputs a number that corresponds to the starting position of the specified string within the input string. As with the other string position numbers, 1 is the first character in the string, 2 is the second, 3 is the third and so on. |
Arguments |
Input 1 {STRING} This input is a string input. This is the string in which the FIND function searches for the specified string. Input 2 {STRING} This input is also a string input and it is the specified string, that is, the FIND function searches for an instance of the Input 2 string within the Input 1 string. For more information on the data types for the inputs and outputs, see Data Type Hierarchy. |
Returns |
Output {DINT} The output is a number that identifies the starting position of the Input 2 string within the Input 1 string (1 is the first character in the string, 2 is the second, 3 is the third and so on). If the output is 0, the Input 2 string cannot be found within the Input 1 string. |
Example:
Function Block Diagram - FIND:
In this example, Input 1 is 'SENSOROVERRIDE' and Input 2 is 'OVERRIDE'. The FIND function searches in the SENSOROVERIDE input for an instance of OVERRIDE. It locates an instance of OVERRIDE starting at the seventh character in the SENSOROVERRIDE input, and so the FIND function outputs 7.
ST Program - FIND:
To use a FIND function in an ST program, you need to use this syntax:
- Output := FIND ('Input 1', 'Input 2');
Where Output, Input 1 and Input 2 are defined as variables earlier in the ST program.