Find String (FIND)
    This information applies to the CompactLogix 5370, ControlLogix 5570, Compact GuardLogix 5370, GuardLogix 5570, Compact GuardLogix 5380, CompactLogix 5380, CompactLogix 5480, ControlLogix 5580, and GuardLogix 5580 controllers.
The FIND instruction locates the starting position of a specified string within another string.
Available Languages
Ladder Diagram

Function Block
This instruction is not available in function block.
Structured Text
FIND (Source,Search,Start,Result);
Operands
There are data conversion rules for mixed data types within an instruction. See Data conversions.
Ladder Diagram and Structured Text
      
  
    
      See Structured Text Syntax for more information on the syntax of expressions within structured text.DescriptionThe FIND instruction searches the Source string for the Search string. If the instruction finds the Search string, the Result shows the starting position of the Search string within the Source string. Otherwise the Results is zero.Affects Math Status FlagsNoMajor/Minor Faults
      
  
    
      None specific to this instruction. See Common Attributes for operand related faults.
Operand  | Type  | Format  | Description  | Notes  | 
|---|---|---|---|---|
Source  | ANY_STRING  | Tag  | The string to search in  | String types are: default STRING data type with max 82 length of characters for the string. any new string type you created with configurable length of characters for the string.  | 
Search  | ANY_STRING  | Tag  | The string to find  | |
Start  | SINT
                   INT
                       DINT  | Immediate
                   tag  | The position in Source to start the search  | Enter a number between 1 and the DATA size of the Source.  | 
Result  | DINT
                   SINT
                       INT  | Tag  | The position in Source where search string was found  | 
A minor fault will occur if:  | Fault Type  | Fault Code  | 
|---|---|---|
The LEN value of the string tag is greater than the DATA size of the string tag.  | 4  | 51  | 
The Start value is invalid, or the Source string is empty.  | 4  | 56  | 
Execution
Ladder Diagram
      
  
    
      Structured Text
      
  
    
      Example
Condition  | Action  | 
|---|---|
Prescan  | N/A  | 
Rung-condition-in is false  | N/A  | 
Rung-condition-in is true  | The instruction executes.  | 
Postscan  | N/A  | 
Condition  | Action  | 
|---|---|
Prescan  | See Prescan in the Ladder Diagram table  | 
Normal execution  | See Rung-condition-in is true in the Ladder Diagram table.  | 
Postscan  | See Postscan in the Ladder Diagram table  | 
A message from a 
MessageView
 terminal contains several pieces of information. The backslash character (\) separates each piece of information. To locate a piece of information, the FIND instruction searches for the backslash character and records its position in find_pos.Ladder Diagram

Structured Text
IF MV_read.EM THEN 
FIND(MV_msg,find,1,find_pos); 
MV_read.EM := 0;
END_IF;
Provide Feedback