Jump to content

Recommended Posts

I made a function to read each line of a file and when I reach EOF, it should exit the func, BUT @error never goes to -1, it stays always equal to 0. Why?

dim $_file = FileOpen("H:\Temp\testFireLinks.txt", 0)

If $_file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    return;Exit
EndIf


; Read in lines of text until the EOF is reached
While 1
    
    dim $_line = FileReadLine($_file)
        
       ;I put the line read to the clipboard, to use later
    ClipPut( $_line ) 
        
    If @error = -1 Then 
        ExitLoop
    EndIf
     
       ;other simple code, then paste the line, with CTRL-V:
    Send('^v')

Wend

FileClose($_file)

Any ideas?

Link to post
Share on other sites

Oh thank you, now it's clear.

So if I made this (I originally thought it to shrink the code) :

ClipPut( FileReadLine($_file) )

I guess I cannot check the @error of File.

So the only way to go is as you told me before, is it true?

Edited by frank10
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...