Jump to content
Sign in to follow this  
cascius

Restarting a While statement on event

Recommended Posts

cascius

Hi everyone, I have a question regarding restarting my main loop from within a function.

I won't share my script as it's very long and could use some serious clean up. Rather I'll give you a simple example:

While 1
_MyFunction_1()
_MyFunction_2()
_MyFunction_3()
_MyFunction_4()
WEnd

Func _MyFunction_3()
If $x = 1 Then
;RESTART THE MAIN While
Else
...
EndIf
EndFunc

So in this example, I want to restart the WHILE when $x = 1, but I'm not sure how this can be done.

I hope somebody can help.

Thanks in advance,

- Olivier

Share this post


Link to post
Share on other sites
jdelaney

look into conditionally using continueloop, or only proceeding to the next _myfunction if the return of the current is as expected

While 1
 _MyFunction_1()
 _MyFunction_2()
 If Not _MyFunction_3() Then ContinueLoop
 _MyFunction_4()
WEnd
--OR--
While 1
 _MyFunction_1()
 _MyFunction_2()
 $bContinue = _MyFunction_3()
 If $bContinue Then _MyFunction_4()
WEnd
--OR--
While 1
 _MyFunction_1()
 _MyFunction_2()
 If _MyFunction_3() Then _MyFunction_4()
WEnd

Func _MyFunction_3()
 If $x = 1 Then
  ;RESTART THE MAIN While
  Return False
 Else
  ...
 EndIf
 Return True
EndFunc   ;==>_MyFunction_3

lots of ways to skin the cat

Edited by jdelaney
  • Like 1

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
cascius

Pretty cool.

I'm surprised I didn't think of that. Thanks a lot for the quick help, this gave me a bunch of ideas.

This can be marked as solved. :)

- Olivier

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  

×