|
By the way this is the code
<%@ language =javascript %>
<html><head><title>tip of the day</title></head><body bgcolor="#ffffff">
<center><h1>Tip of the day</h1>
<%
tips_file = "tips.txt"
// this is the absolute path
//to get the path to the current directory
//file in it (the tip_file, above).
var = abs_path = String(Request.ServerVariables("PATH_TRANSLATED")) ;
//get rid of scripts name in absolute path
//and replace w/name of the file we want to open
var file_to_open = abs_path.replace(/\\w*\.asp/,"\\") + tips_file;
fso = new ActiveXObject ("Scripting.FileSystemObject");
//Make sure we can find tips file before we get carried away
if (fso.FileExists(file_to_open)) {
//open file and read contents:
file_stream = fso.OpenTextFile(file_to_open);
tips_array = new Array ();
//loop through file and collect tips
while (! file_stream.AtEndOfStream){
line_num = file_stream.Line;
tip = file_stream.ReadLine();
tips_array[line_num-1] = tip;
}
file_stream.close();
//Generate random number based on number of tips found and print one
random_number = Math.round((tips_array.lenght-1)* Math.random());
Response.Write("<p>" + tips_array[random_number]);
}// eof if it exists
//if no file found
else {
Response.Write("<p>Sorry the tips file seems to be missing")
}
%>
</center></body></html>
And this is the .txt file Iam reading from:
1. this will be the first tip.
2. This will be the second post.
3. This is the therid of three tips.
__________________
((*
*))
((*
*))
Last edited by atomicstomp; 09-14-2003 at 06:16 PM.
|