Jump to content
Sign in to follow this  
ter-pierre

"Return" command

Recommended Posts

ter-pierre

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
SlimShady

That should work. What's the problem exactly?

Share this post


Link to post
Share on other sites
ter-pierre

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
SumTingWong

Shouldn't it be:

$LINE = FileReadLine($FILE)

:">

Share this post


Link to post
Share on other sites
ter-pierre

Yes. Excuse. the code is

$LINE = FileReadLine($FILE)

still not runnig... :)

Share this post


Link to post
Share on other sites
this-is-me

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
Matt @ MPCS

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.