Hello Everyone,
I was working on some code to create an InStr() function (i know, there are others out there, but I am new to dbpro and wanted to exercise my mind a little) and I got it working. I saved it, re-opened it and then got this error message when compiling:
Compilation Failed: The name 'InStr' duplicated in the program at line 128
However, there is no line 128! Here is the entire code of the program...
Repeat
strS$ = ""
input "String to search: "; strS$
strL$ = ""
input "String to look for: "; strL$
sp = 0
input "Position to start from: "; sp
fp = InStr(sp, strS$, strL$, fp1)
If fp = 0
print "String not found"
else
print "String found at location ", fp
print "Mid check"; Mid$(strS$,fp)
endif
Until INKEY$() = " "
end
function InStr(StartPosition, StrSearch$, StrLook$, FoundPosition)
LenSearch = len(StrSearch$)
LenLook = len(StrLook$)
If Len(StrLook$) > Len(StrSearch$)
FoundPosition = 0
exitfunction FoundPosition
endif
for i = 1 to LenSearch
if i = 1 then i = StartPosition
FoundPosition = i
tempSearch$ = StrSearch$
tempSearch$ = right$(tempSearch$, (len(tempSearch$)-i))
tPart$ = left$(tempSearch$, len(StrLook$))
print tPart$, StrLook$, FoundPosition, i
if tPart$ = StrLook$ Then exitfunction FoundPosition
next i
if FoundPosition = Len(StrSearch$) then FoundPosition = 0
endfunction FoundPosition
function Nz(StrNull$, StrReplace$)
if StrNull$ = "" then StrNull$ = StrReplace$
endfunction StrNull$
Thanks for any help, always appreciated!