Jump to content
Sign in to follow this  
Sardith

FileREad

Recommended Posts

Sardith

$file = FileOpen("test.txt", 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

; Read in lines of text until the EOF is reached
While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
    MsgBox(0, "Line read:", $line)
Wend

FileClose($file)

IS there anyway to read the last line of a .txt file? Or have it read a time stamp, which ever is closes to the current time thats the one it reads? Nothing is mentioned in the Help file.

Format:

12:00:15 PM CPU Temp 31 PWMIC 36 NF4 Chipset 36 GPU 0


[font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font]

Share this post


Link to post
Share on other sites
SmOke_N

$file = FileOpen("test.txt", 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

; Read in lines of text until the EOF is reached
While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
    MsgBox(0, "Line read:", $line)
Wend

FileClose($file)

IS there anyway to read the last line of a .txt file? Or have it read a time stamp, which ever is closes to the current time thats the one it reads? Nothing is mentioned in the Help file.

Format:

12:00:15 PM CPU Temp 31 PWMIC 36 NF4 Chipset 36 GPU 0

Nothing mentioned?

FileReadLine() + _FileCountLines()?


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
seandisanti

$file = FileOpen("test.txt", 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

; Read in lines of text until the EOF is reached
While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
    MsgBox(0, "Line read:", $line)
Wend

FileClose($file)

IS there anyway to read the last line of a .txt file? Or have it read a time stamp, which ever is closes to the current time thats the one it reads? Nothing is mentioned in the Help file.

Format:

12:00:15 PM CPU Temp 31 PWMIC 36 NF4 Chipset 36 GPU 0

you could use _FileReadToArray() and just check that last element of the array...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×