<%
Const ForReading = 1
Dim objQuoteFile, objFSO, strFilePath, iCounter, aQuote, iTotalLines, iThisLine, userPath
userPath = "quotes.txt"
iTotalLines = 0
iCounter = 0
strFilePath = Server.MapPath(userPath)
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
if (objFSO.FileExists(strFilePath)) Then
Set objQuoteFile = objFSO.OpenTextFile(strFilePath, ForReading)
Do While Not objQuoteFile.AtEndOfStream
iTotalLines = iTotalLines + 1
objQuoteFile.ReadLine
Loop
objQuoteFile.Close
if iTotalLines <> 0 Then
Randomize
iThisLine = INT((iTotalLines - 1 + 1) * RND + 1)
Set objQuoteFile = objFSO.OpenTextFile(strFilePath, ForReading)
Do While Not objQuoteFile.AtEndOfStream
if iCounter = iThisLine then
aQuote = objQuoteFile.readline
else
objQuoteFile.ReadLine
end if
iCounter = iCounter+1
Loop
objQuoteFile.Close
Response.Write ""& aQuote&"
"
Else
Response.Write "no quotes"
End if
Set objQuoteFile = Nothing
Else
Response.Write "no file found"
End if
Set objFSO = Nothing
%>