tolyasher Posted November 19, 2008 Posted November 19, 2008 I have small question related to code below:Code 1 (This code is working properly):While 1 Local $LineRead = FileReadLine($hFile) If (@error = -1) Then ExitLoop ConsoleWrite( " " & @error & @CRLF) ConsoleWrite( " " & $LineRead & @CRLF) WEndCode 2 ( I see that '@error = -1' in the Console but this code is never stop):While 1 Local $LineRead = FileReadLine($hFile) ConsoleWrite( " " & @error & @CRLF) If (@error = -1) Then ExitLoop ConsoleWrite( " " & $LineRead & @CRLF) WEndWhy?Thanks in advance!
Nahuel Posted November 19, 2008 Posted November 19, 2008 The value of @error is set to 0 when a function is called. So, you are evaluating ConsoleWrite's @error value on the second code. Try this: While 1 Local $LineRead = FileReadLine($hFile) $error = @error ConsoleWrite( " " & $error & @CRLF) If ($error = -1) Then ExitLoop ConsoleWrite( " " & $LineRead & @CRLF) WEnd
tolyasher Posted November 19, 2008 Author Posted November 19, 2008 The value of @error is set to 0 when a function is called. So, you are evaluating ConsoleWrite's @error value on the second code. Try this: While 1 Local $LineRead = FileReadLine($hFile) $error = @error ConsoleWrite( " " & $error & @CRLF) If ($error = -1) Then ExitLoop ConsoleWrite( " " & $LineRead & @CRLF) WEnd Thank you very much. I thought that "ConsoleWrite" do not affect error flag because it do not described in the AutoIT Help
Richard Robertson Posted November 19, 2008 Posted November 19, 2008 There are several undocumented changes to @error. A few scripts even started reading these values before, but it's not a good idea.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now