<body>
<a href=listsearch.asp?opt=1>opt=1 good view</a><br>
<a href=listsearch.asp?opt=2>opt=2 array view</a><br>
<a href=listsearch.asp?opt=3>opt=3 plain text</a><hr>
<%
dim ar, opt, result, allrec, i, rp, sp
opt = request.querystring("opt")
result = "error"
set ftxt=createobject("scripting.filesystemobject")
set ln = ftxt.opentextfile(server.mappath("/cgi-bin/search.dat"))
if opt = 1 then
response.write("<ol>")
do while not ln.atendofstream
ar = split(ln.readline,":",-1,1)
response.write("<li>" & ar(0))
response.write(" <a href=http://" & ar(1) &">")
response.write(ar(1) &"</a> " & ar(2))
loop
response.write("</ol>")
result = "ok"
end if
if opt = 2 then
allrec = ln.readall
ar = split(allrec,chr(10),-1,1)
response.write("<ol>Total record : "&ubound(ar))
for i = 0 to ubound(ar)-1
sp = split(ar(i),":",-1,1)
rp = replace(ar(i),sp(1)," [<b>"&sp(1)&"</b>]<br>")
response.write("<li>"&sp(0)&rp&sp(2))
next
response.write("</ol>")
result = "ok"
end if
if opt = 3 then
allrec = ln.readall
response.write("<pre>")
response.write(allrec)
response.write("</pre>")
result = "ok"
end if
if opt = "" then
response.write("No option")
end if
ln.close
response.write "<hr>List : " & result
%>
</body>
จำนวน : 47 บรรทัด