Search Search

#1 worldwide
FREE Coding Lessons

since 1996
   THE BEST WAY to learn ASP & Asp.net!
Advertise Here!
click for details
Credits Host:
DiscountASP.net
Server Admin:
The "Team"
Contact Info.
Charles M. Carroll

my Blog
[prev. Lesson]  Text Files: Meyers-Briggs parsing #1
     [next Lesson]  Text Files: Meyers-Briggs parsing #3

Reading/Parsing an ASCII File #2 by Charles Carroll

Here is one implementation of parsing the file and converting it to on-the-fly HTML.

   filename=/learn/test/mb.asp

<Test Script Below>


<%option explicit%>
<html>

<head>
<title>mb.asp</title>
</head>

<body bgcolor="#FFFFFF">

<form method="post" action="mbrespond.asp">
<%
dim answer1, answer2
dim char1, char2, counter
Dim fs, findslash, findhyphen
dim rest
Dim thisfile, thisline
dim question
dim whichfile
whichfile=server.mappath("mb.txt")
Set fs = CreateObject("Scripting.FileSystemObject")
Set thisfile = fs.OpenTextFile(whichfile, 1, False)
counter=0
do while not thisfile.AtEndOfStream
    counter=counter+1
    thisline=thisfile.readline
    char1=mid(thisline,1,1)
    char2=mid(thisline,2,1)
    rest=mid(thisline,3)

    findhyphen=instr(thisline,"-")
    question=mid(rest,1,findhyphen-2)

    rest=mid(rest,findhyphen)
    findslash=instr(rest,"/")
    answer1=mid(rest,1,findslash-1)
    answer2=mid(rest,findslash+1)

    'response.write char1 & "<br>"
    'response.write char2 & "<br>"
    'response.write rest & "<p>"
    response.write question & "<br>"
    'response.write answer1 & "<br>"
    'response.write answer2 & "<p>"
    %>
  <p><input TYPE="radio" name="Q<%=counter%>" VALUE="U" CHECKED>Undecided<br>
  <input TYPE="radio" name="Q<%=counter%>" VALUE="<%=char1%>"><%=answer1%><br>
  <input TYPE="radio" name="Q<%=counter%>" VALUE="<%=char2%>"><%=answer2%></p>
  <p><%
loop
thisfile.Close
set fs=nothing
%> <input type="submit"></p>
</form>
</body>
</html>

Chaz Wish List
Tall Tip $5
Grande Tip $20
Venti Tip $39
Tip Jar Thanks
2004 Thanks
2005 Thanks
HUGE Tip -love site