Solved

Expected end of statement-- ASP

Posted on 2008-06-20
5
818 Views
Last Modified: 2010-04-21
Hi,

I am making a program in ASP

Which will browse into the directory and filter image files. We should be able to delete those images

I got some code from below URL

http://www.asp101.com/articles/john/imageviewer/default.asp

I used the code, but I get the error:


Technical Information (for support personnel)

Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/ASPImageProject/browsedir1.asp, line 60, column 28
objFile.Type = "JPEG Image" Then
---------------------------^


Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)

Page:

The code in the above URL is below. I get the same type of code in many other sites but all give the same errors

Please guide
<%@ Language=VBScript %>
<% Option Explicit %>
<%
Const ImageFilePath = "images"
Const DeleteButtonLabel = "Delete Selected Images"
 
Dim objFSO
Dim objFolder
Dim objFile
 
Dim strFileName
Dim strFileExtension
 
Dim blnShowImages
 
If Request.QueryString("ShowImages") = "" Then
    blnShowImages = False
Else
    blnShowImages = CBool(Request.QueryString("ShowImages"))
End If
 
If Request.Form("btnDelete") = DeleteButtonLabel Then
    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
 
    For Each strFileName In Request.Form("delete")
        objFSO.DeleteFile(Server.MapPath(ImageFilePath & "/" & _
            strFileName))
    Next
 
    Set objFSO = Nothing
End If
%>
<html>
<head>
  <title>ASP 101 Image Browser & Killer!</title>
</head>
<body>
 
<form action="<%= Request.ServerVariables("URL") %>" method="post">
 
<table border="1">
<tr>
    <th>Image Name</th>
    <th>Image <a href="<%= Request.ServerVariables("URL") %>?
        ShowImages=<%= Not blnShowImages %>">(Toggle Display)</a></th>
    <th>Delete This Image</th>
</tr>
<%
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(Server.MapPath(ImageFilePath))
 
For Each objFile In objFolder.Files
	strFileExtension = LCase(Mid(objFile.Name, _
		InStrRev(objFile.Name, ".", -1, 1) + 1))
 
	If strFileExtension = "gif" Or strFileExtension = "jpg" Or _
		strFileExtension = "jpeg" Then
	' Original image file identification option:
	'If objFile.Type = "GIF Image" Or _
		objFile.Type = "JPEG Image" Then
        %>
        <tr>
        <td>
            <a href="<%= ImageFilePath & "/" & objFile.Name %>">
            <%= objFile.Name %></a>
        </td>
        <%
        If blnShowImages Then
            %>
            <td>
                <img src="<%= ImageFilePath & "/" & objFile.Name %>" />
            </td>
            <%
        Else
            %>
            <td>
                <a href="<%= ImageFilePath & "/" & objFile.Name %>">
                View Image</a>
            </td>
            <%
        End If
        %>
        <td align="center">
            <input type="checkbox" name="delete"
            value="<%= objFile.Name %>" />
        </td>
        <%
    End If
Next
 
Set objFolder = Nothing
Set objFSO = Nothing
%>
<tr>
    <td colspan="3" align="right">
        <input type="submit" name="btnDelete"
        value="<%= DeleteButtonLabel %>">
    </td>
</tr>
</table>
 
</form>
 
</body>
</html>

Open in new window

0
Comment
Question by:tia_kamakshi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 21832408
Could you try again without breaking the IF statement into two lines....e.g.

If objFile.Type = "GIF Image" Or  objFile.Type = "JPEG Image" Then
0
 
LVL 29

Expert Comment

by:rdivilbiss
ID: 21832452
http://www.rodsdot.com/spider_images.asp

using

if  (file.type="GIF Image") or (file.type="JPEG Image") then
0
 
LVL 82

Accepted Solution

by:
hielo earned 300 total points
ID: 21833240
The problem is that these lines:
      ' Original image file identification option:
      'If objFile.Type = "GIF Image" Or _
            objFile.Type = "JPEG Image" Then

should be only two:
      ' Original image file identification option:
      'If objFile.Type = "GIF Image" Or objFile.Type = "JPEG Image" Then

The last line is a continuation of the one before it, that's why the one before it ends in "_", meaning "this statement continues on the next line

If you really want to keep it in three lines, you need to comment the last line as well by prexing it with an apostrophe. Otherwise the system will try to execute that line by itself (like it is doing now) and will give you the error because Then is NOT tied to an If clause since the If is commented. Again, if you want it in three lines, this is what you need:
      ' Original image file identification option:
      'If objFile.Type = "GIF Image" Or _
      '      objFile.Type = "JPEG Image" Then
0
 
LVL 15

Assisted Solution

by:dosth
dosth earned 200 total points
ID: 21836975
just remove this lines

' Original image file identification option:
        'If objFile.Type = "GIF Image" Or _
                objFile.Type = "JPEG Image" Then
0
 

Author Closing Comment

by:tia_kamakshi
ID: 31469208
Many Thanks
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
return false must be hit after calling certain command 10 45
Debugging Html 8 32
Html split(text) Part2 6 25
Diff of the day 2 10
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question