Ask Ozmo Sample ASP Code
<%
On Error Resume Next
If Request.Form("hname") = "" Then
' This part of the script allows a person
' to enter data on an HTML form. This is html form that you ask Ozmo the question.
' once the user hits the Ask Ozmo button, the form fills the hname variable and runs the
' second part of the script that pulls a random answer from the answer text file.
%>
<HTML>
<HEAD><TITLE>Ask Ozmo</TITLE></HEAD>
<BODY BGCOLOR=#99CC99 TOPMARGIN=0 LEFTMARGIN=0>
<TABLE BORDER=0 WIDTH=100% CELLPADDING=0 CELLSPACING=0>
<TR><TD ALIGN=CENTER>
<FONT FACE="Comic Sans MS" COLOR=GREEN><H1>Ask the Great Cosmic Ozmo</H1></FONT>
<FONT FACE="Comic Sans MS" SIZE=6 COLOR="#000000">
<P>The great cosmic Ozmo will give you the answers to all your questions.</P>
<HR>
<%
'This is the HTML Form that you enter your question to ask ozmo.
'It contains a Hidden form variable that will force the asp file
'to run the second script
%>
<FORM METHOD=POST ACTION="askozmo.asp">
<FONT FACE="Comic Sans MS" SIZE=6 COLOR=#000000><P>What is your question?</FONT>
<INPUT TYPE=TEXT SIZE=50 MAXLENGTH=50 NAME="Question"><BR>
<INPUT TYPE=HIDDEN NAME="hname" VALUE="hvalue" >
<INPUT TYPE=SUBMIT VALUE="Ask Ozmo"><INPUT TYPE=RESET VALUE="Reset Form">
</FORM>
<BR>
</TD>
<TD ALIGN=RIGHT VALIGN=TOP><IMG SRC="/workshop/server/asp/ozmo.jpg" HEIGHT=238 WIDTH=160 ALT="The Great Cosmic Ozmo"></TD>
</TR>
</FONT>
</TABLE>
</BODY>
</HTML>
<% Else
' This part of the script runs once somebody hits the ASK Ozmo button.
' This part creates a HTML responce by pulling a random quote out of the
' ask ozmo answer file.
%>
<HTML>
<BODY BGCOLOR=#99CC99 TOPMARGIN=0 LEFTMARGIN=0>
<CENTER>
<TABLE BORDER=0 WIDTH=100% CELLPADDING=4 CELLSPACING=1>
<TR><TD ALIGN=LEFT HEIGHT=50>
<FONT FACE="Comic Sans MS" COLOR="#000000"><H1>The Great Ozmo says:</H1></FONT>
</TD>
<TD ALIGN=RIGHT VALIGN=TOP ROWSPAN=2 WIDTH=300 HEIGHT=238>
<IMG SRC="/workshop/server/asp/lgozmo.gif" HEIGHT="238" WIDTH="300" ALT="The Great Cosmic Ozmo">
</TD>
</TR>
<TR>
<TD ALIGN=RIGHT VALIGN=TOP HEIGHT=188>
<%
'Get a connection to the ASP File object.
'Point the file object to the ozmo.txt file. This is the answer file.
Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
strquotefile = (Server.MapPath("/") + "/workshop/server/asp/ozmo.txt")
Set InStream = FileObject.OpenTextFile (strquotefile, 1, FALSE, FALSE)
'Get a random quote from the file.
'First, Read the amount of quotes in the file. This is the first line of ozmo.txt
NumQuote = Instream.ReadLine
'Second, Create a random number between 0 and the Number of Quotes.
randomize
QuoteNumber = Int((NumQuote ) * Rnd )
'Third, Skip lines until you have reached the random quote line.
while QuoteNumber > 0
InStream.SkipLine()
QuoteNumber = QuoteNumber-1
wend
'Then, Read the Quote
OzmoQuote = Instream.ReadLine
'And write the Quote out. Each quote line is standard HTML.
Response.Write OzmoQuote
'Reset the File Object.
Set InStream = Nothing
%>
</TD>
</TR>
<TR>
<TD ALIGN=CENTER COLSPAN=2>
<FONT FACE="Comic Sans MS" SIZE=4 COLOR=black><A HREF="askozmo.asp">Go back and ask Ozmo another question.</A></FONT>
</TD>
</TR>
</TABLE>
</CENTER>
</BODY>
</HTML>
<% End If %>