ter-pierre Posted October 18, 2004 Posted October 18, 2004 Some one have an exemple of use of the "return" function on a While...Wend loop? I´m trying the code above inside of a UDF but is not running fine... While 1 $LINE = FileReadLine($tmpfile) If @Error = -1 Then ExitLoop If $LINE=@UserName Then Return 1 WEnd
SlimShady Posted October 18, 2004 Posted October 18, 2004 That should work. What's the problem exactly?
ter-pierre Posted October 18, 2004 Author Posted October 18, 2004 Here is the complete code... $FILE = InputBox("Question", "Input file...", "", "", -1, -1, 0, 0) If INFILE($FILE) Then MsgBox(0,"TEST","username in file") Else MsgBox(0,"TEST","username NOT in file") EndIf Func INFILE($FILE) While 1 $LINE = FileReadLine($tmpfile) If @Error = -1 Then ExitLoop If $LINE=@UserName Then Return 1 WEnd EndFunc
SumTingWong Posted October 18, 2004 Posted October 18, 2004 Shouldn't it be: $LINE = FileReadLine($FILE) :">
ter-pierre Posted October 18, 2004 Author Posted October 18, 2004 Yes. Excuse. the code is $LINE = FileReadLine($FILE) still not runnig...
this-is-me Posted October 18, 2004 Posted October 18, 2004 Return returns from a function Exitloop returns from a while or do loop ContinueLoop allows the loop to skip to the next item Who else would I be?
Matt @ MPCS Posted October 18, 2004 Posted October 18, 2004 (edited) The problem with your code is your IF statement: $FILE = InputBox("Question", "Input file...", "", "", -1, -1, 0, 0) If INFILE($FILE) Then MsgBox(0,"TEST","username in file") Else MsgBox(0,"TEST","username NOT in file") EndIf Func INFILE($FILE) While 1 $LINE = FileReadLine($tmpfile) If @Error = -1 Then ExitLoop If $LINE=@UserName Then Return 1 WEnd EndFunc If statements can only be all on a single line OR completly seperated. *** Matt @ MPCS EDIT: Apparently formatting isn't allowed nested within code blocks. Edited October 19, 2004 by Matt @ MPCS
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