Topic: DMD0166

STRFIND - Find within String


The Find within String (STRFIND) instruction will search the target string for a match to a second String or a string literal.

 

If the specified 'Search from' is 'Beginning to end', and the STRFIND operation is successful, the 'Where Found' value can be used programmatically as the Offset value in the Get Sub-String (STRSUB), Delete Sub-String (STRDELETE), and Insert Sub-String (STRINSERT) instructions.

Parameters:

Note: Use the F9 key (Element Browser) or Down-Arrow key (Auto-Complete) at any time to see a complete list of the memory locations that are valid in the current field of the instruction.

 

Find within - this can be any String element.

 


Search From - designates the direction of the search
 

  • Beginning to end - select this option to begin the search at the first character in the Find within String
     

  • End to beginning - select this option to begin the search at the last character in the Find within String

 


Case Sensitive - designates whether the case of the characters is relevant in the comparison
 

  • Yes, upper/lower case are different - select this option if the comparison needs to distinguish between upper case and lower case versions of the same characters, that is, "A" is NOT the same as "a"
     

  • No, upper/lower case are equal - select this option if the comparison does not need to distinguish between upper case and lower case versions of the same characters, that is, "A" is the same as "a"

 


In Offset: Start  /  Out Offset: Where Found - is an input AND output parameter.

 

As the input parameter (In Offset: Start) specifies the character offset into the Find within string to begin the search.

 

As the output parameter (Out Offset: Where Found) stores the character offset in the Find within String where the Find Text/String was found if the STRFIND operation was successful. If there are multiple potential matches, this will contain the offset of the first match. The offset value is relative to the end of the String where the search begins. For example, if the String SS0 contains "ABCDEFG", a STRFIND that searched for "C" will find it at fffset 3 when searching from 'Beginning to end', but will find it at offset 5 when searching from 'End to beginning'.

 

Both the In Offset: Start and Out Offset: Where Found values are 0-based.

 

If no match is found this value will be set to -1.

 


Set If Found - select this option to have the designated bit set ON if a match is found. This can be any writable bit location.

 

Set If Not Found - select this option to have the designated bit set ON if a match is not found. This can be any writable bit location.

 


Find Text/String - is the text to look for in the Find within String. This can be any String element, or a string literal.
 

  • Exact sequence - select this option to specify that all of the characters of the Find Text/String must be found in the exact order in the Find within String to constitute a match
     

  • Any one of these characters - select this option to specify that finding any one of the characters of the Find Text/String found in any order in the Find within String will constitute a match.

 


Status Display:

The Status display of the Find within String instruction will only display as many of the characters of the Find within String and Find Text/String as will fit within the borders of the instruction, typically this is about 50 characters.

 

The gray triangle at the right end of an input leg indicates the input is edge triggered.

 


See Also:

 


Related Topics:

String Functions Overview

 

String Scripting Language Reference

 


Example: