Forum Moderators: open
working with instr function in an ASP page.
code functions and finds all urls 0-100 per page.
The problem is that either it crashes or it goes into an infinate loop. What have i missed that it doesn'break out of the loop properly.
' Actually Sends the request and returns the data:
xml.Send
' buffers response to string var
strBuffer=xml.ResponseText
'sets counters and loop length.
strLen = Len(strBuffer)
curserloc = 1
count = 0
do while curserloc < strLen
count = count + 1
'finds string
strstart = instr(curserloc,strBuffer,"PgIenyDetail.jsp?hiddenNotary=" )
if strstart then text = mid(strBuffer,strstart,38)
curserloc = strstart + 38
Response.Write text & " " & curserloc & " " & strLen & " " & count & "<BR>"
loop
It was trying to figure out how to stop the looping process. the only working approach I have got working is the following:
while strstart
count = count + 1
strstart = instr(curserloc,strBuffer,"PgIenyDetail.jsp?hiddenNotary=" )
if strstart then
text = mid(strBuffer,strstart,38)
Names(count) = text
Response.Write Base & Names(count) & " " & curserloc & " " & strstart & " " & count & "<BR>"
curserloc = strstart + 38
else
strstart =0
Response.Write " " & curserloc & " " & strstart & " " & count & "<BR>"
end if
wend
Although, something in that lacks elagance and why didn't it return a null or an out of bounds error when I tried to go beyond the string length. Why did it restart at the begining and start to research.
Thank you,
placbill