View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
external usenet poster
 
Posts: 2,824
Default FileSystemObject to get last 10 lines of text file.

Does the last line mean wscript.echo? If yes, then this is the equivalent of a
msgbox. It was there to show the that the data was retrieved--not to be used in
real life?

If you're checking lots of times just to see if there are changes, then maybe
you could use an API that watches for changes.

Randy Birch's VBNet site has some code that uses API calls to watch a folder.
Try http://www.mvps.org/vbnet

look for: FindChangeNotification

john wrote:

Hi Dave,

Thanks for the link.

I gave the code a quick go (Excel) and it fell flat on it's face. Before I
go asking how to make it work, were you pointing to this code as a 'how to'
within VBA, or an indication as to the results using that approach?

If there are no HUGE benefits from the FileSystemObject, then the File Line
# method is probably the quickest/appropriate direction, yes? (Although I
stepped through a procedure and watched it go over and over till it got to
the last line:(

To explain a little further (Hi Tom): The file in question is a logfile that
updates by adding a few extra lines of data each time an action/change is
made within a -browser based- application (which I cannot gain access to or
control). The section (Say 10 lines detailing Log-off time) I'm interested
in catching, is appended when the application closes/logs off.

I have looked into detecting the Findwindow (title) to detect when the
application isn't in use, as a bases to either check the logfile, or record
a time when the application was stopped... But that was a no go, as the
application is itself appears to be running within an application and whats
worse, the window title doesn't change even when a different role is being
performed within that application... Thats right, it's a horrible situation!

So I'm back to looking at the end of the log-file every time a change occurs
within the application, which funnily enough, I can detect via the FileDate
change function to detect file properties.

Now that I've wrote out all the negatives, I bet I've also convinced you I'm
on a looser!

Thanks again!

Dave Peterson wrote in message
...
I searched google in the *scripting* newsgroup and found this:

http://groups.google.com/groups?thre...%40tkmsftngp10

The last post in the thread contained this:

This code takes 4 seconds to get last 10 lines out of 221,000 Lines regdmp
File.



john wrote:

Hi there,

I am interested in finding out how to read the last 10 lines (or so) of

a
text file using the FileSystemObject function, rather than looping

through a
text file line-by-line until the end is reached then working backwards.

I may be looking at reading the last 10 lines of a large text file

almost
every second, and would be interested in the fastest method available.

If anyone can explain how this could be done, I'd be very grateful!

Thank you.


--

Dave Peterson


--

Dave Peterson