home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 March / VPR9703A.ISO / MS_DEV / VID / SERVER / ASF / DATA.Z / ts.asp < prev    next >
Text File  |  1996-10-22  |  1KB  |  38 lines

  1. <HTML>
  2. <BODY>
  3. <H3>Textstream test</H3>
  4. <%
  5.   Set FileObject = Server.CreateObject("Scripting.FileSystemObject")
  6.   TestFile = Server.MapPath ("/ASPSamp") & "\samples\tsworks.txt"
  7.   Set OutStream= FileObject.CreateTextFile (TestFile, TRUE, FALSE)
  8.   OutputString = "This is a test..." & Now()
  9.   OutStream.WriteLine OutputString
  10.   Response.Write "Wrote the string '" & OutputString & "' to the file: '" & TestFile & "'<P>"
  11.   Set OutStream = Nothing
  12.  
  13.   Response.Write "Reading from file '" & TestFile & "':<BR>"
  14.   Set InStream= FileObject.OpenTextFile (TestFile, 1, FALSE, FALSE)
  15.   While not InStream.AtEndOfStream
  16.     Response.Write Instream.Readline & "<BR>"
  17.     InStream.SkipLine()
  18.   wend
  19.   Set Instream=nothing
  20.  
  21.   Randomize
  22.   TipNumber = Int((10 - 1 + 1) * Rnd + 1)
  23.   
  24.   Response.Write "<P>The Tip Number is: " & TipNumber & "<P>"
  25.  
  26.   strtipsfile = (Server.MapPath("/advworks") + "\tips.txt")
  27.   Set InStream = FileObject.OpenTextFile (strtipsfile, 1, FALSE, FALSE)
  28.   while TipNumber > 0
  29.     InStream.SkipLine()
  30.     TipNumber = TipNumber-1
  31.   wend
  32.   TipOfTheDay = Instream.ReadLine
  33.   Response.Write  "The Tip of the Day is: <BR><B>" & TipOfTheDay & "</B>"
  34.   Set InStream = Nothing
  35. %>
  36. </BODY>
  37. </HTML>
  38.