Jump to content

Recommended Posts

Posted

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

Posted

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

Posted (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 by Matt @ MPCS

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...