Solved

Ending ReadLine at EOF

Posted on 2002-05-15
3
1,642 Views
Last Modified: 2012-08-14
Using the Object FSO I want to read each line to a variable. Some sample for clarity:

Set objTextStream = objFSO.OpenTextFile(FileToOpen, 1)
'Want to have line below read until EOF
txtMsg = objTextStream.ReadLine

What is the syntax for EOF so it does not error out?
0
Comment
Question by:dmoring
  • 2
3 Comments
 
LVL 3

Expert Comment

by:tejaspurani
ID: 7011390
objTextStream.AtendOfStream  


T.P.
0
 
LVL 3

Accepted Solution

by:
tejaspurani earned 50 total points
ID: 7011394

<%
Option Explicit
' Set up constants
Const ForReading = 1
Const Create = False

' Declare local variables
Dim objFSO         ' FileSystemObject
Dim objTextStream  ' TextStreamObject
Dim strLine        ' local variable to store Line
Dim strFileName    ' local variable to store fileName

strFileName = Server.MapPath("textfile.txt")

' Instantiate the FileSystemObject
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

' use Opentextfile Method to Open the text File
Set objTextStream = objFSO.OpenTextFile(strFileName, ForReading, Create)

If Not objTextStream.AtEndOfStream  Then  

Do While Not objTextStream.AtendOfStream  

strLine = objTextStream.ReadLine ' Read one line at a time
Response.Write strLine ' Display that line
Response.Write "<br>"  
 
Loop

End If

' close TextStreamObject
' and destroy local variables to relase memory
objTextStream.Close
Set objTextStream = Nothing
Set objFSO = Nothing
%>
0
 

Author Comment

by:dmoring
ID: 7059009
Worked great!!! Thank you!
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Use a variable for Class Name in Classic ASP 4 54
Select distinct 25 97
Passing Parameter to Stored Procedure 4 22
Select case on click 3 13
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now