Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error: With End With Statement

Status
Not open for further replies.

larryman

Programmer
Jun 16, 2000
63
US
Please,

I can't figure out exactly what could be wrong with this block of code.

With GetTitle
.Global = False
.IgnoreCase = True
.Pattern = &quot;<title>(.|\n)*</title>&quot;
End With

This block causes error when i run the code i got from someone in the community.

The Error message is:
Microsoft VBScript compilation error '800a0400'

Expected statement

/webapps/helpdesk/search.asp, line 117

With Regex
^


Oysterbar ride to success. Keep Riding
 
I believe this error is being caused by something above that statement not being finished or ended. Did you forget to end a previous with statement?
Try running just this(by itself) in a script and you should see what I mean:
Code:
<%
Option Explicit
Dim GetTitle
Set GetTitle = New Regexp
With GetTitle
        .Global = False
        .IgnoreCase = True
        .Pattern = &quot;<title>(.|\n)*</title>&quot;
End With
%>

Let me know what turns up,
-Tarwn ________________________________________________________________________________
Sometimes it is how you ask the question: faq333-2924
Many ASP questions have already been answered, please check faq333-3048 and use the search tool before posting
 
Here is the whole code. I corrected a place that has Set GetTitle = Regexp to Set Get Title = New Regexp.

I however got a new error:
Microsoft VBScript compilation error '800a03ea'

Syntax error

/webapps/helpdesk/search.asp, line 114

Set GetTitle = New RegExp
----------------^



I have below the whole code for clarity.


<%
Response.Buffer=True
%>
<html>
<head>
<title></title>

</head><body>
<FORM method=&quot;get&quot; action=&quot;search.asp?type=getinfo&quot; id=form1 name=form1>
<input name=&quot;query&quot; size=&quot;16&quot; class=&quot;form&quot; >
</td>
<td align=&quot;right&quot;><input type=submit value=&quot;go&quot; border=&quot;0&quot; width=&quot;30&quot; height=&quot;26&quot; id=image1 name=image1></td>
</tr>
</table></FORM>
<%

' Globals --------------------------------------
' ----------------------------------------------

Const ValidFiles = &quot;htmltxt&quot;
Const RootFld = &quot;./&quot;

Dim Matched
Dim Regex
Dim GetTitle
Dim fs
Dim rfLen
dim RootFolder
Dim DocCount
Dim DocMatchCount
Dim MatchedCount

' ----------------------------------------------
' Procedure: SearchFiles()
' ----------------------------------------------
Public Sub SearchFiles(FolderPath)
Dim fsFolder
Dim fsFolder2
Dim fsFile
Dim fsText
Dim FileText
Dim FileTitle
Dim FileTitleMatch
Dim MatchCount
Dim OutputLine

' Get the starting folder
Set fsFolder = fs.GetFolder(FolderPath)
' Iterate thru every file in the folder
For Each fsFile In fsFolder.Files
' Compare the current file extension with the list of valid target files
If InStr(1, ValidFiles, Right(fsFile.Name, 3), vbTextCompare) > 0 Then
DocCount = DocCount + 1
' Open the file to read its content
Set fsText = fsFile.OpenAsTextStream
FileText = fsText.ReadAll
' Apply the regex search and get the count of matches found
MatchCount = Regex.Execute(FileText).Count
MatchedCount = MatchedCount + MatchCount
If MatchCount > 0 Then
DocMatchCount = DocMatchCount + 1
' Apply another regex to get the html document's title
Set FileTitleMatch = GetTitle.Execute(FileText)
If FileTitleMatch.Count > 0 Then
' Strip the title tags
FileTitle = Trim(replace(Mid(FileTitleMatch.Item(0),8),&quot;</title>&quot;,&quot;&quot;,1,1,1))
' In case the title is empty
If FileTitle = &quot;&quot; Then
FileTitle = &quot;No Title (&quot; & fsFile.Name & &quot;)&quot;
End If
Else
' Create an alternate entry name (if no title found)
FileTitle = &quot;No Title (&quot; & fsFile.Name & &quot;)&quot;
End If
' Create the entry line with proper formatting
' Add the entry number
OutputLine = &quot; <b>&quot; & DocMatchCount & &quot;.</B> &quot;
' Add the document name and link
OutputLine = OutputLine & &quot;<A href=&quot; & chr(34) & RootFld & replace(Mid(fsFile.Path, rfLen),&quot;\&quot;,&quot;/&quot;) & chr(34) & &quot;><B>&quot;
OutputLine = OutputLine & FileTitle & &quot;</B></a>&quot;
' Add the document information
OutputLine = OutputLine & &quot;<font size=1><br> Criteria matched &quot; & MatchCount & &quot; times - Size: &quot;
OutputLine = OutputLine & FormatNumber(fsFile.Size / 1024,2 ,-1,0,-1) & &quot;K bytes&quot;
OutputLine = OutputLine & &quot; - Last Modified: &quot; & formatdatetime(fsFile.DateLastModified,vbShortDate) & &quot;</Font><br>&quot;
' Display entry
Response.Write OutputLine
Response.Flush
End If
fsText.Close
End If
Next

' Iterate thru each subfolder and recursively call this procedure
For Each fsFolder2 In fsFolder.SubFolders
SearchFiles fsFolder2.Path
Next

Set FileTitleMatch = Nothing
Set fsText = Nothing
Set fsFile = Nothing
Set fsFolder2 = Nothing
Set fsFolder = Nothing
End Sub

' ----------------------------------------------
' Procedure: Search()
' ----------------------------------------------
Sub Search(SearchString)
Dim i
Dim fKeys
Dim fItems

Set fs = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set GetTitle = New RegExp
Set Regex = New RegExp

With Regex
.Global = True
.IgnoreCase = True
.Pattern = Trim(SearchString)
End With
With GetTitle
.Global = False
.IgnoreCase = True
.Pattern = &quot;<title>(.|\n)*</title>&quot;
End With

RootFolder = Server.MapPath(RootFld)

If Right(RootFld,1) <> &quot;/&quot; Then
RootFld = RootFld & &quot;/&quot;
End If

If Right(RootFolder, 1) <> &quot;\&quot; Then
RootFolder = RootFolder & &quot;\&quot;
End If
rfLen = Len(RootFolder) + 1

SearchFiles RootFolder

If MatchedCount = 0 Then
Response.Write &quot; <B>No Matches Found.</b><BR>&quot;
End If

Set Regex = Nothing
Set GetTitle = Nothing
Set fs = Nothing

End Sub


If Trim(Request(&quot;query&quot;)) <> &quot;&quot; Then
%>
<hr>
<table border=&quot;0&quot; width=&quot;100%&quot; bgcolor=&quot;#ACD6D6&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
<tr>
<td width=&quot;100%&quot;><Font Color=&quot;#FFFFFF&quot; Size=&quot;2&quot;> Your search for <B><%=Request(&quot;query&quot;)%></B> found the following documents:</Font></td>
</tr>
</table>
<BR><BR>
<%
Response.Flush
Search Request(&quot;query&quot;)
If DocCount > 0 Then
%>
<BR>
<Font Size=1>
(The search criteria &quot;<%=Request(&quot;query&quot;)%>&quot; found <%=MatchedCount%> times in <%=DocMatchCount%> of <%=DocCount%> documents.)
</font>
<%
End If
End If
%>
<BR><BR>
<hr><div align=&quot;center&quot;>
</Font>
</td>
</tr>
</table>
</body>
</html>

<%
Public Sub header
%>

<%
end sub
Response.End
%></BODY></HTML> Oysterbar ride to success. Keep Riding
 
This may be as simple as:

[tt]Set fs = Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)[/tt] --James
 
Thanks,

I have made the amendment in the code but i still got the error. Oysterbar ride to success. Keep Riding
 
JamesLean,

I found that i run version 3.0 and i need to upgrade it. Any suggestion on this.

Thanks a lot Oysterbar ride to success. Keep Riding
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top