Solved

VBScript Question

Posted on 2004-08-11
2
188 Views
Last Modified: 2010-03-18
Someone please tell me why this script never exits the Loop PLEASE!

On Error Resume Next

Const ForReading = 1, ForWriting = 2, ForAppending = 8

Dim fso, f, s

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:\testfile.txt", ForReading, True)
Do While NOT f.AtEndOfStream
   s = f.readline
   wscript.Echo s
   f.Close
Loop

0
Comment
Question by:Packerland
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 31

Expert Comment

by:merowinger
ID: 11774228
try:
while NOT f.AtEndOfStream
   s = f.readline
   wscript.Echo s
   f.Close
Loop
0
 
LVL 14

Accepted Solution

by:
JohnK813 earned 500 total points
ID: 11774250
Try moving your f.Close outside the loop (as in, after it).  f.Close closes your stream, so that's probably why you're never getting an AtEndOfStream signal.

Do While NOT f.AtEndOfStream
   s = f.readline
   wscript.Echo s
Loop
f.Close
0

Featured Post

Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

Question has a verified solution.

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

The Need In an Active Directory enviroment, the PDC emulator provide time synchronization for the domain. This is important since Active Directory uses Kerberos for authentication.  By default, if the time difference between systems is off by more …
I'm a big fan of Windows' offline folder caching and have used it on my laptops for over a decade.  One thing I don't like about it, however, is how difficult Microsoft has made it for the cache to be moved out of the Windows folder.  Here's how to …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

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