Click to See Complete Forum and Search --> : Random Images


WandaLL
12-08-2003, 06:43 PM
:confused:

I am using the following script in an includes file but when I try to run the file that the include is in, I get an error message that says "Expected end of statement
/sdu/PluggedIn_new/includes/rotating_faces.inc, line 16, column 9".

This is where it is breaking:
Dim path As String = Server.MapPath(Session("VirtualBasePath")) & "/about_sdu/whos_who/database.txt"

Any ideas as to why this is happening? --Thanks...

This is the rest of the code:

<script language="JavaScript1.1">
<!--

/*Browsercheck:*/
if(document.all){
var ie=document.all?1:0;
//var n=0
}else{
var n=document.layers?1:0;
}

<%

'create file path to database

Dim path As String = Server.MapPath(Session("SDUVirtualBasePath")) & "/about_sdu/whos_who/database.txt"

'open the file
Dim sduAssociates As StreamReader
sduAssociates = File.OpenText(path)

'initialize counter

Dim counter As Integer = 0

'search through database
Dim name As String
Dim bio As String
Dim title As String
Dim alpha As String
Dim group As String
Dim splitName As String
Dim splitName2 As String

While sduAssociates.Peek() <> -1

name = sduAssociates.ReadLine()
bio = sduAssociates.ReadLine()
title = sduAssociates.ReadLine()
alpha = sduAssociates.ReadLine()
group = sduAssociates.ReadLine()
sduAssociates.ReadLine()

counter = counter + 1

'Create the link array

if instr(name, "'") then
splitName = Left(name, instr(name, "'") - 1)
splitName2 = Right(name, len(name) - instr(name, "'"))
name = splitName & splitName2
end if

response.write("var image" & counter & "=new Image()" & chr(10))
response.write("image" & counter & ".src=""" & Session("SDUSiteBase") & "/images/about_sdu/associates/" & name & ".jpg""" & chr(10) & chr(10))

End While

' close and clean up

sduAssociates.Close()
%>
//-->
</script>
<script language="JavaScript1.2">
function reapply(){
setTimeout("slideit()",3000)
return true
}
window.onerror=reapply
</script>
<base target="_self">
<script>
<!--

//change speed below (in seconds)
var speed=3
var random
var destHREF
Link=new Array()
AssociateName=new Array()
<%
'create file path to database

path = Server.MapPath(Session("SDUVirtualBasePath")) & "/about_sdu/whos_who/database.txt"

'open the file
sduAssociates = File.OpenText(path)

'initialize counter

counter = 0

'search through database

While sduAssociates.Peek() <> -1

name = sduAssociates.ReadLine()
bio = sduAssociates.ReadLine()
title = sduAssociates.ReadLine()
alpha = sduAssociates.ReadLine()
group = sduAssociates.ReadLine()
sduAssociates.ReadLine()

'Create the link array

if instr(name, "'") then
splitName = Left(name, instr(name, "'") - 1)
splitName2 = Right(name, len(name) - instr(name, "'"))
name = splitName & splitName2
end if

response.write("Link[" & counter & "]=""" & Session("SDUSiteBase") & "/about_sdu/whos_who/pop_up_associate.asp?id=" & name & """" & chr(10))
response.write("AssociateName[" & counter & "]=""" & name & """" & chr(10) & chr(10))

counter = counter + 1

End While

' close and clean up

sduAssociates.Close()
%>

function initIt(){
sdu_Name.style.filter = "blendTrans(duration=3)"
slideit();
}

function slideit(){
//alert("ok")
random=Math.round(Math.random()*<%=counter - 1%> )
destHREF=Link[random-1]
if (!document.images)
return
if (document.all)
sdu_Name.filters.blendTrans.Apply();
slide.filters.blendTrans.Apply();
sdu_Name.innerHTML = AssociateName[random-1];
document.images.slide.src = eval("image"+random+".src");
slide.filters.blendTrans.Play();
sdu_Name.filters.blendTrans.Play();
if (document.all)
setTimeout("slideit()",speed*1000+3000)
else
setTimeout("slideit()",speed*1000)
}

//-->
</script>

MichaelM
12-09-2003, 11:04 AM
In "classic" ASP, declaring and initializing a variable on the same line is not allowed.
Try:
[code]
Dim path
path = Server.MapPath(Session("VirtualBasePath")) & "/about_sdu/whos_who/database.txt"
[\code]

WandaLL
12-10-2003, 06:10 PM
That worked but then I got an "Expected statement" error message on this line:

End While

MichaelM
12-11-2003, 11:13 AM
Try replacing

End While

with

Wend


For more info check here:
VBScript Documentation (http://msdn.microsoft.com/library/en-us/script56/html/vsstmWhile.asp)