Reply
JScript error, Expected ';' but where?
Old 11-03-2009, 03:04 PM JScript error, Expected ';' but where?
Average Talker

Posts: 15
Trades: 0
Hi all,
I recently found some code that allowed me to display a random image without having to name the images a specific name. Instead I could just throw in an image to a directory and the JavaScript will just pick an image randomly. Testing the code I find it is not happy with the syntax, and although it has narrowed it down to a line and a clue, having placed the ';' in various positions the same error continues to bug me. The error message is quoted below, can anyone please point me in the right direction?

Error Type:
Microsoft JScript compilation (0x800A03EC)
Expected ';'
/bigdogz/rndm.asp, line 12, column 6
Const IMGS_DIR = "/miscimages/";
-----^
Thanks in advance,
Mitch...
CMitch07 is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 11-03-2009, 05:58 PM Re: JScript error, Expected ';' but where?
chrishirst's Avatar
Super Moderator

Posts: 22,281
Location: Blackpool. UK
Trades: 0
error messages do not always point to the line the error is in, but to the line when the interpreter/compiler encoutered an error.

In this case it will probably in the line above.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Growing old is mandatory - Growing up is optional
Code Samples | People Counting System | Bits & Bobs
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-04-2009, 01:41 PM Re: JScript error, Expected ';' but where?
Average Talker

Posts: 15
Trades: 0
Cheers Chris.

There is a ; in one of the lines above but not so sure that is the culprit.
I have the full code pasted below in case you see soemthing i'm missing:

<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<%
Const IMGS_DIR = "./miscimages/"
Dim objFSO, objFolderObject, objFileCollection, objFile
Dim intFileNumberToUse, intFileLooper
Dim objImageFileToUse
Dim strImageSrcText
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolderObject = objFSO.GetFolder(Server.MapPath(IMGS_DIR))
Set objFSO = Nothing
Set objFileCollection = objFolderObject.Files
Set objFolderObject = Nothing
intFileNumberToUse = Int(objFileCollection.Count * Rnd) + 1
intFileLooper = 1
For Each objFile in objFileCollection
If intFileLooper = intFileNumberToUse Then
Set objImageFileToUse = objFile
Exit For
End If
intFileLooper = intFileLooper + 1
Next
Set objFileCollection = Nothing
strImageSrcText = IMGS_DIR & objImageFileToUse.Name
Set objImageFileToUse = Nothing
%>
<h3>Method #3:</h3>
<img src = "<%= strImageSrcText %>" width = "500" height = "500" alt = "Random Image"/>
<br/>
<%
%>
</body>
</html>

Thanks again,
Mitch....
CMitch07 is offline
Reply With Quote
View Public Profile
 
Old 11-04-2009, 01:48 PM Re: JScript error, Expected ';' but where?
chrishirst's Avatar
Super Moderator

Posts: 22,281
Location: Blackpool. UK
Trades: 0
the code you have there is VbScript not jscript.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Growing old is mandatory - Growing up is optional
Code Samples | People Counting System | Bits & Bobs
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-04-2009, 02:30 PM Re: JScript error, Expected ';' but where?
Average Talker

Posts: 15
Trades: 0
DOH !!
Well spotted, and i've made the necessary corrections and it now works.
Thanks so much !
CMitch07 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to JScript error, Expected ';' but where?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.12226 seconds with 13 queries