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 Sting Literal Zero or more characters enclosed in double quotes, as in "hello", and may include both simple escape sequences (such as \t for the tab character) and hexadecimal data (such as 0xAA).. 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 or click the 'three dot box' at the right edge of the parameter field to open the Default Element Selection Tool (the Element Picker or the Element Browser) or use the Down-Arrow key (Auto-Complete) on any parameter field to see a complete list of the memory locations that are valid for that parameter of the instruction.
Find within - this can be any User-defined or System-defined String.
Search From - designates the direction of the search
In Offset: Start / Out Offset: Where Found - is an input AND output parameter. Both the In Offset: Start and Out Offset: Where Found values are 0-based.
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 0-based character offset in the Find within String where the Find Text / String was found if the 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 offset 2 when searching from 'Beginning to end', but will find it at offset 4 when searching from 'End to beginning'. 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 Sting Literal Zero or more characters enclosed in double quotes, as in "hello", and may include both simple escape sequences (such as \t for the tab character) and hexadecimal data (such as 0xAA)..
Input Leg selects which of the following power-flow conditions will cause this instruction to run:
|
|
Status Display:
The Status display will only show 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.
|
|
See Also:STR2REAL - Convert String to Real
STR2INT - Convert String to Integer
STRCASE - Convert String to UPPER / lower Case
STRCOPYR - Copy a Range of Strings
STRFIND - Find within String
|
|
Related Topics:
String Scripting Language Reference
|
|
Example:
|
|