
| <%
@ Language="JavaScript"
%>
<HTML> <BODY> <H1>Quote Of The Day:</H1> <% var abs_path; var quotes = "Quotes.txt"; // this gives us
the absolute path of this script which we'll use abs_path = String(Request.ServerVariables("PATH_TRANSLATED")); // get rid of
script name in absolute path file_to_open = abs_path.replace(/\\\w*\.asp/,"\\") + quotes; var fso = new ActiveXObject("Scripting.FileSystemObject"); // Make sure we can find quotes file before we get carried away if (fso.FileExists(file_to_open))
{ var Quotes = new Array(); while (! file_stream.AtEndOfStream)
{ //
loop through file and collect tips quote = file_stream.ReadLine(); // read the line in the file & assign it to quote Quotes[line_num
- 1] = quote; file_stream.Close(); // generate random number based on number of quotes we found and print one. random_number = Math.round((Quotes.length - 1) * Math.random()); Response.write("<P>"
+ Quotes[random_number]); %> </BODY> |