'-----------------------------------------------------
'                 (c) 2003 MCS Electronics
'         INSTR function demo
'-----------------------------------------------------
$regfile = "M103DEF.DAT"
$crystal = 4000000
$baud = 9600

'dimension variables
Dim Pos As Byte
Dim S As String * 8 , Z As String * 8

'assign string to search
S = "abcdeab"                                                 ' Z = "ab"

'assign search string
Z = "ab"

'return first position in pos
Pos = Instr(s , Z)
'must return 1

'now start searching in the string at location 2
Pos = Instr(2 , S , Z)
'must return 6


Pos = Instr(s , "xx")
'xx  is not in the string so return 0

End
