Solved

Ending ReadLine at EOF

Posted on 2002-05-15
3
1,638 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

911 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

20 Experts available now in Live!

Get 1:1 Help Now