%@ Language=JavaScript %>
|
|
Science
and the Art of Skeptical Thought |
|||||||
| <% var tips_file = "sciquotes.txt"; // this gives us the absolute path of this script which we'll use // to get the path to the current directory so we can open a // file in it (the tips_file, above). var abs_path = String(Request.ServerVariables("PATH_TRANSLATED")); // get rid of script name in absolute path // and replace with name of 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 we found and print one. random_number = Math.round((tips_array.length-1) * Math.random()); Response.Write(tips_array[random_number]); } // end of if file exists // if we can't find file else { Response.Write("Sorry, the quotes file seems to be missing!") } %> | ||||||||
|
|
||||||||
|
Skeptical Thought, Critical Thinking, and Logic Skeptical Organizations Psychics UFOs and Extraterrestrial Phenomena Reference Creationism and Religion Miscellaneous Doing your research on the Web? Great! Just be sure you're not using bogus information: |
|||||||
|
I'm sorry to say that my e-mail has been spammed out by lowlife spammers. I can't provide an e-mail link here, because the spambots will simply invade my newest e-mail addy. You can reach me manually, though - just send your e-mail to mike at kohary dot com (simply turn the bolded text into an e-mail address by inserting the appropriate symbols in the right places). Thanks, and I'm sorry for the inconvenience. |
||||||||