FC6A S
ERIES
MICROS
MART
L
ADDER
P
ROGRAMMING
M
ANUAL
FC9Y-B1726 26-39
26: S
CRIPT
Example 7.32 Search a string
Script
Operation Description
Searches for the search string "DEFG" that starts from D0200 in the string to be searched "ABCDEFGHIJKLMNO" that starts from
D0100 and stores the position of the occurrence of the string in D0000. If not found, -1 is stored in D0000.
If "?" is specified as a character to search for, it is handled as any single-byte character.
When specifying "?" (0x3F) as a character, specify it as "~?" (0x7E3F) in two bytes.
When specifying "~" (0x7E) as a character, specify it as "~~" (0x7E7E) in two bytes.
Note: The maximum length of the search string is 128 characters.
When searching for "DEFG" and the string was found
When searching for "WXYZ" and the string was not found
[D0000] = STRSTR([D0100], [D0200]);
Search string String to be searched Search result
Device Stored Value Device Stored Value
Position
Device Stored Value
D0200
Upper Byte
'D' = 0x44
D0100
Upper Byte
'A' = 0x41 0
D0000 3
Lower Byte
'E' = 0x45
Lower Byte
'B' = 0x42 1
D0201
Upper Byte
'F' = 0x46
D0101
Upper Byte
'C' = 0x43 2
Lower Byte
'G' = 0x47
Lower Byte
'D' = 0x44
←3
D0202
Upper Byte
0x00
Terminating character
D0102
Upper Byte
'E' = 0x45 4
Lower Byte
0x00
Lower Byte
'F' = 0x46 5
D0103
Upper Byte
'G' = 0x47 6
Lower Byte
'H' = 0x48 7
D0104
Upper Byte
'I' = 0x49 8
Lower Byte
'J' = 0x4A 9
D0105
Upper Byte
'K' = 0x47 10
Lower Byte
'L' = 0x4C 11
D0106
Upper Byte
'M' = 0x4D 12
Lower Byte
'N' = 0x4E 13
D0107
Upper Byte
'O' = 0x4F 14
Lower Byte
0x00
Terminating character
Search string String to be searched Search result
Device Stored Value Device Stored Value
Position
Device Stored Value
D0200
Upper Byte
'W' = 0x57
D0100
Upper Byte
'A' = 0x41 0
D0000 -1
Lower Byte
'X' = 0x58
Lower Byte
'B' = 0x42 1
D0201
Upper Byte
'Y' = 0x59
D0101
Upper Byte
'C' = 0x43 2
Lower Byte
'Z' = 0x5A
Lower Byte
'D' = 0x44 3
D0202
Upper Byte
0x00
Terminating character
D0102
Upper Byte
'E' = 0x45 4
Lower Byte
0x00
Lower Byte
'F' = 0x46 5
D0103
Upper Byte
'G' = 0x47 6
Lower Byte
'H' = 0x48 7
D0104
Upper Byte
'I' = 0x49 8
Lower Byte
'J' = 0x4A 9
D0105
Upper Byte
'K' = 0x47 10
Lower Byte
'L' = 0x4C 11
D0106
Upper Byte
'M' = 0x4D 12
Lower Byte
'N' = 0x4E 13
D0107
Upper Byte
'O' = 0x4F 14
Lower Byte
0x00
Terminating character