I also have an instr() function, just for the sake of it...
Syntax = instr(string to be searched in, string to be looked for, nth occurence of string)
It returns the position of the string (that is the position of the first character of it) and 0 if it isn't found. The third parameter is used for different occurences. So if there was a string...
"hellomehellome"
and you said..
instr("hellomehellome", "me", 1)
It would return 6 as the 1st occurence is 6 characters along. However if you did ...
instr("hellomehellome", "me", 2)
Then it would return 13 as the second occurence of 'me' is 13 characters along.
function instr(string1$, string2$, numoc)
result = 0
occount = 0
if string1$ = "" or string2$ = "" or numoc <= 0 or len(string2$)>len(string1$) then exitfunction 0
for x = 1 to 1 + len(string1$) - len(string2$)
curstr$ = ""
for y = x to x + len(string2$) - 1
curstr$ = curstr$ + mid$(string1$, y)
next y
if curstr$ = string2$
occount = occount + 1
if occount = numoc
result = x
exit
endif
endif
next x
endfunction result
cuRant PRogekt: a three-de map editer
Why the hell'd you ask me for crying out loud!?!
Athelon XP 1400 Plus - Nvidia Geforce MX400 - 256mb RAM