<% '-------- 'Initialize variables... '-------- set myFile = Server.CreateObject("Scripting.FileSystemObject") set fileObject = myFile.GetFile(Request.ServerVariables("PATH_TRANSLATED")) set parentDir = fileObject.ParentFolder 'The above gets the path to the current parent directory and stores it in parentDir dataFile = parentDir & "\slides.mdb" '-------- 'Is this a new session or not? '-------- if session("slidetotal") = "" then 'New User Session 'Make sure Database exists... if myFile.FileExists(dataFile) then '...if so, make the connection set con = Server.CreateObject("ADODB.Connection") Con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dataFile else '...otherwise create a new DB set myData = Server.CreateObject("ADOX.Catalog") myData.Create "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dataFile MySql = "CREATE TABLE SLIDES(imgfile VARCHAR(80) PRIMARY KEY, descrip VARCHAR(255))" set con = Server.CreateObject("ADODB.Connection") Con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dataFile Con.Execute(MySql) end if 'next step through files and populate array 'make sure each file exists in DB, 'otherwise add new file to DB with blank Description counter = 1 dim slideArray() redim slideArray(200) set myDir = myFile.GetFolder(parentDir) for each thing in myDir.Files if right(thing,3) = "jpg" or right(thing,3) = "gif" then imgFilename = right(thing,len(thing)-len(parentDir)-1) slideArray(counter) = imgFilename MySql = "SELECT * FROM SLIDES WHERE left(IMGFILE,2) = '" & left(imgFilename,2) & "'" set RS= Con.Execute(MySql) if RS.EOF then response.write imgfile &"," & descrip MySql = "INSERT INTO SLIDES (imgfile, descrip) VALUES('" & imgFilename & "','')" Con.Execute(MySql) end if counter = counter + 1 end if next 'store total number of active slides for session Session("slidetotal") = counter - 1 Redim PRESERVE slideArray(session("slidetotal")) Session("slideArray") = slideArray else 'this is not a new session, but a continuing one -- make sure connection to DB is open set con = Server.CreateObject("ADODB.Connection") Con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & datafile 'also set slideArray to point to the stored session array slideArray = Session("slideArray") end if '-------- 'Last page clicked on Start Over '-------- if session("slideno") = "" or Request.QueryString("slide") = "start" then session("slideno") = 1 end if '-------- 'Last page clicked on Next '-------- if Request.QueryString("slide") = "next" then if session("slideno") < session("slidetotal") then session("slideno") = cint(session("slideno")) + 1 end if end if '-------- 'Last page clicked on Prev '-------- if Request.QueryString("slide") = "previous" then if session("slideno") > 1 then session("slideno") = cint(session("slideno")) - 1 end if end if '-------- 'Initialize record set from DB to contain description '-------- 'get filename for current image to display MySql = "SELECT * FROM SLIDES WHERE left(IMGFILE,2) = '" & left(slideArray(session("slideno")),2) & "'" set currentImageRS = Con.Execute(MySql) %> Slides <% '-------- 'Show the Picture '-------- %>

">

<% '-------- 'Display Counter X of Y '-------- %> <% '-------- 'Display Previous Button if not first slide '-------- %> <% '-------- 'Display Next Button if not last slide '-------- %> <% '-------- 'Display Start Over button '-------- %> <% '-------- 'Display description of slide '-------- %>
<%Response.Write Session("slideno") & " of " & session("slidetotal")%>
<%if Session("slideno") <> 1 then%>

<%end if%>
<%if cint(session("slideno")) < cint(session("slidetotal")) then%>

<%end if%>

<%= currentImageRS("descrip")%>