Sign in to follow this  
Followers 0
ter-pierre

"Return" command

7 posts in this topic

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

Share this post


Link to post
Share on other sites



That should work. What's the problem exactly?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Shouldn't it be:

$LINE = FileReadLine($FILE)

:">

Share this post


Link to post
Share on other sites

Yes. Excuse. the code is

$LINE = FileReadLine($FILE)

still not runnig... :)

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

#7 ·  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

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  
Followers 0