Parsing question

justonemore

Active Member
When parsing, say a simple text file. Is there a command to go to very last line?
Trying to script a very basic HS script for status of my UPS. There is an eventviewer file that came with my APC software. Basicly I just want the last line of the viewer.

TIA
 
JOM,
You have to basically read every line and store the last line in a variable until EOF or end of file is reached then the variable will contain the last line. Try this:

Code:
sub main()
Dim fso, file

    Path = "c:\temp\text.txt"
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set file = fso.OpenTextFile(Path, ForReading, True)
      Do Until file.AtEndOfStream
        r = file.ReadLine
      Loop
    file.Close
    MsgBox ("This is the last line : " & r)
end sub
 
Thanks Rupp.
Ran into a little snag though. Looks like the EventViewer is an app that reads from eventlog.dat. Since eventviewer is an app itself (even though it basicly displays like notepad), it's not a text file itself. Trying to open the eventlog.dat file proves hopeless. Just a bunch of gargly gook. :)
 
Jom,
I couldn't get the viewer to run because it was looking for other .dll's. With out knowing all the offsets it's going to be all but impossible to parse a binary file. Do you have the option to use a comma separated file?
 
That's a big NEGATIVE. They do however have an upgrade on their site. Downloading and installing now. Perhaps this ver will be more user friendly for data!????
 
Damn. No luck their either. Maybe I'll just email them and see what they have to say. MAN.....I hate when a simple little idea turns into a full blown project :)
 
I hate when a simple little idea turns into a full blown project

Welcome to the world of Home Automation ;)

It ALWAYS seems to turn into something much bigger than anticipated, dosent it?
 
Back
Top