<% response.write (get_str()) response.write (get_str()) response.write (get_str()) function get_str() server.ScriptTimeout = 900 dim fso,txt_name,txt_path,tatol_line,times,fp,ForReading,f_path ForReading = 1 txt_path = "txt/" '小说文件夹绝对路径 txt_name = "story.txt" '小说的名字 f_path = server.mappath(txt_path & txt_name) times = Time'时间 ' response.write (f_path) Set fso = Server.CreateObject("Scripting.FileSystemObject") If (not fso.FileExists(f_path)) Then get_str = "小说目录中[" &txt_name & "]文件不存在." exit function End If set fp = fso.getFile (f_path) If (fp.Size < 10) Then get_str = "[" &txt_name & "]太小." exit function End If set fp = fso.OpenTextFile(f_path,ForReading,false) tatol_line = fp.ReadLine() if (not IsNumeric(tatol_line)) then get_str = "[" &txt_name & "]第一行不是数字." fp.close() exit function end if tatol_line = cint(tatol_line) if (VarType(tatol_line) <> 2) then get_str = "[" &txt_name & "]第一行不是整数." fp.close() exit function end if if (tatol_line < 2) then get_str = "[" &txt_name & "]第一行数字必须大于2,也就是内容必须二行以上." fp.close() exit function end if ' response.write(tatol_line) dim rd_line Randomize rd_line = Int((tatol_line - 1 + 1) * Rnd(1) + 1) while (fp.AtEndOfStream=false) and ((rd_line) > fp.line) fp.skipline wend get_str = fp.readLine() & " -- " & times fp.close() end function %>