Sign in to follow this  
Followers 0
shag

continueloop question

15 posts in this topic

I have one main while loop and have couple while loops inside

my structure is like

while 1

;some codes

while *condition*

;some codes

wend

if *condition*

continueloop

endif

wend

when i did this continueloop restarts the code back to the loop inside not the main loop.

I tried to look for some example, but i think i'm the only one with this problem.. lol how can I fix this?

thank you in advance!

Share this post


Link to post
Share on other sites



Do you have a working example?

Share this post


Link to post
Share on other sites

You say you have one main while loop with two while loops inside but I'm only seeing one while loop inside of there.

I have continueloop after the second loop for starting back to main loop, but it also goes back to the second loop not the main loop

Share this post


Link to post
Share on other sites

Probably start by using the level paramater for ContinueLoop().

I was wondering what I need to put in there 1 or some other number?

Share this post


Link to post
Share on other sites

Do you have a working example?

it's not my code, so i didn't want to pose it online for the respect for distributor, but is that really needed? I can make an example that work i guess..

Share this post


Link to post
Share on other sites

it's not my code, so i didn't want to pose it online for the respect for distributor, but is that really needed? I can make an example that work i guess..

A really simple **working** example would help...as jaberwocky said your structure example doesn't seem match your description of the problem.

Share this post


Link to post
Share on other sites

A really simple **working** example would help...as jaberwocky said your structure example doesn't seem match your description of the problem.

while 1

$load=0
$counter=0

While ($load=0 AND $counter<50)
$load = _ImageSearchArea("loading.BMP",0,$centre_x-35,$centre_y-100,$centre_x+35,$centre_y-10,$loading_x,$loading_y,80)
$counter = $counter + 1
WEnd

if $load=0 Then
ContinueLoop
EndIf

$loaded=0
$countersec=0

While ($loaded=0 AND $countersec<50)
$load = _ImageSearchArea("loaded.BMP",0,$centre_x-35,$centre_y-100,$centre_x+35,$centre_y-10,$loading_x,$loading_y,80)
$countersec = $countersec + 1
WEnd

if $loaded=0 Then
ContinueLoop
EndIf

WEnd

so this is basically the code. what I want is for ContinueLoop to go back to main while loop "while 1" not the loop inside above the if statement.

Share this post


Link to post
Share on other sites

Try this:

While ($load=0 AND $counter<50)
        $load = _ImageSearchArea("loading.BMP",0,$centre_x-35,$centre_y-100,$centre_x+35,$centre_y-10,$loading_x,$loading_y,80)
        $counter = $counter + 1
        If $load = 50 and $counter = 49 Then ContinueLoop(2)
WEnd

it might not work, but do you see what I am getting at?

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

All your instances of ContinueLoop are in the outer loop. There is no way ContinueLoop is taking it back into one of the nested loops. But with that example I don't know how you would know the difference, since on returning to the start of the outer loop, normal program flow takes it right back into the first nested loop anyway.

;)

Edit: Maybe this helps to see how it's working:

HotKeySet("{ESC}", "_Quit")

While 1
    ConsoleWrite("Top of loop 1" & @LF)

    $a = 0
    $b = 0

    While ($a = 0) And ($b < 5)
        ConsoleWrite($a & "-" & $b & @LF)
        $b += 1
        Sleep(500)
    WEnd

    If $a = 0 Then ContinueLoop

    ConsoleWrite("End of loop 1" & @LF)
WEnd

Func _Quit()
    Exit
EndFunc   ;==>_Quit
Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

All your instances of ContinueLoop are in the outer loop. There is no way ContinueLoop is taking back into one of the nested loops. But with that example I don't know how you would know the difference, since on returning to the start of the outer loop, normal program flow takes it right back into the first nested loop anyway.

;)

there are more codes in the the main while loop

I have tested the code with mousemove to see if the continueloop brings it back to main loop or not

Share this post


Link to post
Share on other sites

anyone know the right way of using level for ContinueLoop?

I tried ContinueLoop(2), ContinueLoop [2], and ContinueLoop[2]...

non of them works..

Share this post


Link to post
Share on other sites

...nvm i think it was somekind of weird bug...

I moved the if statement to front(untab) now it works.. lol

thanks everyone who replied!

Share this post


Link to post
Share on other sites

anyone know the right way of using level for ContinueLoop?

I tried ContinueLoop(2), ContinueLoop [2], and ContinueLoop[2]...

non of them works..

Here's an example:
For $a = 0 To 3
    For $b = 0 To 3
        For $c = 0 To 3
            Sleep(500)
            If $b = 2 Then ContinueLoop 2
            ConsoleWrite($a & "-" & $b & "-" & $c & @LF)
        Next
    Next
Next

The ContinueLoop statement is in the "c" loop, and without any argument (or 1) would just return to the top of the "c" loop. With a 2 it goes back to the "b" loop, and if it had a 3 it would go back to the "a" loop.

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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