Solved

Ending ReadLine at EOF

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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 …
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

707 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

17 Experts available now in Live!

Get 1:1 Help Now