Any idea why I get server out of memory with this search code
<%
Dim iCount
Dim arrSearchTerm
GetFilenames
'----------------------------------------------------
'Name: Searchit(Filename)
'Purpose: Text based in site search engine
'Parmaters: strFilename (String)- Page to be searched
' : strSearchTerm (String) - text Search term
'Author: Shaun Hare
'Date: 18.06.04
'Version: 1.0
'Revision date:
'-------------------------------------------------------
Function Searchit(strFilename,strSearchTerm)
'Declare variables
Dim Text2Search
Dim arrSearchText
Dim countn
Dim SearchCount
'Initiate file contents to search through
Text2Search=FileStream(strFilename)
'Make array top search through
arrSearchText=Split(Text2Search," ")
SearchCount=0
'Search array
For x = 0 to ubound(arrSearchText)
if arrSearchText(x)=strSearchTerm then
arrSearchTerm(SearchCount,0)=strFilename
arrSearchTerm(SearchCount,1)=getTitle(Text2Search)
SearchCount=SearchCount+1
iCount=iCount+1
End if
Next
set arrSearchtext=nothing
End Function
Function Filestream(strFilename)
'---------------------------------------------------------
'Name: Filestream
'Purpose: Get filestream from file
'Date: 21.06.04
'Author:Shaun Hare
'Version:
' Revision date:
'----------------------------------------------------------
'Declare Variables
Dim objFso
Dim objTxtStr
Dim tmpstr
'create component objects for file opening
Set objFso=Server.CreateObject("Scripting.Filesystemobject")
'check if file exists either in the root or from fully qualified path
If objFso.fileExists(strfilename) then
' file exists so read into string variable
Set objTxtStr=objFs
penTextFile(strFilename)
tmpStr=objTxtStr.readAll()
else
'no file so return blank string
tmpStr=""
end if
Set objFso=nothing
Set objTxtStr=nothing
Filestream=tmpStr
End function
Function getTitle(strContents)
'-------------------------------------------------------------------------
'Name: getTitle
'Purpose: Regular Expression function to get the title of an HTML page
'Date 21.06.04.
'Author: Shaun Hare
'Version
'Revision Date
'-------------------------------------------------------------------------
Dim objRegExp
Set objRegExp = New RegExp
'Set the regular expression pattern
objRegExp.Pattern = "<title>(.*?)<\/title>"
objRegExp.IgnoreCase = True
objRegExp.Global = True
'Get the matches from the contents of our HTML file, strContents
Dim objMatches
Set objMatches = objRegExp.Execute(strContents)
'if there are matches then return it as a response from the function
If objMatches.Count > 0 then
getTitle=Mid(objMatches(0).Value, 8, Len(objMatches(0).Value) - 16)
Else
getTitle= "NO TITLE"
End If
'destroy object in memory
Set objRegExp = Nothing
End function
Function GetFilenames()
'Recursive Folder Search
Dim objFiles
Dim base
Dim objFileSys, objFolder, objSubFolder
Dim strLF
Dim bolAfter
Set objFileSys = Server.CreateObject("Scripting.FileSystemObject")
'Grab the information of the folder specified by section
base=Server.MapPath("/customers/existing/havelok") ' base folder
Set objFolder = objFileSys.GetFolder(base)
'If iCount > # of hits per page, exit function
Const iListPerPage = 9
if iCount > iListPerPage then Exit Function
bolAfter=True
For each objFiles in objFolder.Files
if not Left(objFolder.name,1)="_" then
if not left(objFiles.name,1)="." then
if Request.QueryString("strLF")="" then
Searchit objFiles.path,Request.QueryString("terms")
If iCount > iListPerPage then
strLF = FormatURL(objFile.Path)
exit function
End If
For Each objSubFolder in objFolder.SubFolders
GetFilenames
Next
else
if objFiles.path=FormatURL(Request.QueryString("strLF")) then
bolAfter=true
end if
If bolAfter=True then
Searchit objFiles.path,Request.QueryString("terms")
If iCount > iListPerPage then
strLF = FormatURL(objFile.Path)
exit function
End If
For Each objSubFolder in objFolder.SubFolders
GetFilenames
Next
End if
End if
End if
End if
Next
Set objFileSys=nothing
End function
Function FormatURL(strPath)
'Cut off everything before and replace all \ with /
Dim iPos
Dim str
iPos = InStr(1,strPath," str = Mid(strPath,iPos+7,Len(strPath))
FormatURL = Replace(str,"\","/")
End Function
Response.write("Occurences=" & icount)
%>
<%
Dim iCount
Dim arrSearchTerm
GetFilenames
'----------------------------------------------------
'Name: Searchit(Filename)
'Purpose: Text based in site search engine
'Parmaters: strFilename (String)- Page to be searched
' : strSearchTerm (String) - text Search term
'Author: Shaun Hare
'Date: 18.06.04
'Version: 1.0
'Revision date:
'-------------------------------------------------------
Function Searchit(strFilename,strSearchTerm)
'Declare variables
Dim Text2Search
Dim arrSearchText
Dim countn
Dim SearchCount
'Initiate file contents to search through
Text2Search=FileStream(strFilename)
'Make array top search through
arrSearchText=Split(Text2Search," ")
SearchCount=0
'Search array
For x = 0 to ubound(arrSearchText)
if arrSearchText(x)=strSearchTerm then
arrSearchTerm(SearchCount,0)=strFilename
arrSearchTerm(SearchCount,1)=getTitle(Text2Search)
SearchCount=SearchCount+1
iCount=iCount+1
End if
Next
set arrSearchtext=nothing
End Function
Function Filestream(strFilename)
'---------------------------------------------------------
'Name: Filestream
'Purpose: Get filestream from file
'Date: 21.06.04
'Author:Shaun Hare
'Version:
' Revision date:
'----------------------------------------------------------
'Declare Variables
Dim objFso
Dim objTxtStr
Dim tmpstr
'create component objects for file opening
Set objFso=Server.CreateObject("Scripting.Filesystemobject")
'check if file exists either in the root or from fully qualified path
If objFso.fileExists(strfilename) then
' file exists so read into string variable
Set objTxtStr=objFs

tmpStr=objTxtStr.readAll()
else
'no file so return blank string
tmpStr=""
end if
Set objFso=nothing
Set objTxtStr=nothing
Filestream=tmpStr
End function
Function getTitle(strContents)
'-------------------------------------------------------------------------
'Name: getTitle
'Purpose: Regular Expression function to get the title of an HTML page
'Date 21.06.04.
'Author: Shaun Hare
'Version
'Revision Date
'-------------------------------------------------------------------------
Dim objRegExp
Set objRegExp = New RegExp
'Set the regular expression pattern
objRegExp.Pattern = "<title>(.*?)<\/title>"
objRegExp.IgnoreCase = True
objRegExp.Global = True
'Get the matches from the contents of our HTML file, strContents
Dim objMatches
Set objMatches = objRegExp.Execute(strContents)
'if there are matches then return it as a response from the function
If objMatches.Count > 0 then
getTitle=Mid(objMatches(0).Value, 8, Len(objMatches(0).Value) - 16)
Else
getTitle= "NO TITLE"
End If
'destroy object in memory
Set objRegExp = Nothing
End function
Function GetFilenames()
'Recursive Folder Search
Dim objFiles
Dim base
Dim objFileSys, objFolder, objSubFolder
Dim strLF
Dim bolAfter
Set objFileSys = Server.CreateObject("Scripting.FileSystemObject")
'Grab the information of the folder specified by section
base=Server.MapPath("/customers/existing/havelok") ' base folder
Set objFolder = objFileSys.GetFolder(base)
'If iCount > # of hits per page, exit function
Const iListPerPage = 9
if iCount > iListPerPage then Exit Function
bolAfter=True
For each objFiles in objFolder.Files
if not Left(objFolder.name,1)="_" then
if not left(objFiles.name,1)="." then
if Request.QueryString("strLF")="" then
Searchit objFiles.path,Request.QueryString("terms")
If iCount > iListPerPage then
strLF = FormatURL(objFile.Path)
exit function
End If
For Each objSubFolder in objFolder.SubFolders
GetFilenames
Next
else
if objFiles.path=FormatURL(Request.QueryString("strLF")) then
bolAfter=true
end if
If bolAfter=True then
Searchit objFiles.path,Request.QueryString("terms")
If iCount > iListPerPage then
strLF = FormatURL(objFile.Path)
exit function
End If
For Each objSubFolder in objFolder.SubFolders
GetFilenames
Next
End if
End if
End if
End if
Next
Set objFileSys=nothing
End function
Function FormatURL(strPath)
'Cut off everything before and replace all \ with /
Dim iPos
Dim str
iPos = InStr(1,strPath," str = Mid(strPath,iPos+7,Len(strPath))
FormatURL = Replace(str,"\","/")
End Function
Response.write("Occurences=" & icount)
%>