Jump to content

Priority problem SOLVED


joeyone
 Share

Recommended Posts

i have a loop and 4 functions

the problem is that i only want the loop to execute one function at a time

i explain deeper

when the loop enters the first time

i want it to only execute function1, if function 1 is TRUE then i want to run function1 even next time the loop executes

but if function1 is FALSE then when the loop executes i want it to choose function2 instead

and if function2 is true then execute it next time but if its FALSE go for function3 and so on...

i hope someone can help me in this matter

For $i = 1 To 64 Step +1
    
    function1()
    function2()
    function3()
    function4()
Next

Func function1()
;code
EndFunc

Func function2()
;code
EndFunc

Func function3()
;code
EndFunc

Func function3()
;code
EndFunc
Edited by joeyone
Link to comment
Share on other sites

Like this?

$runNext = 1

For $i = 1 To 64 Step +1
    Select 
        
        Case $runNext = 1
            If function1() Then
                $runNext = 1
            Else
                $runNext = 2
            EndIf
            
        Case $runNext = 2
            If function2() Then
                $runNext = 2
            Else
                $runNext = 3
            EndIf
            
        Case $runNext = 3
            If function3() Then
                $runNext = 3
            Else
                $runNext = 4
            EndIf
            
        Case $runNext = 4
            If function4() Then
                $runNext = 4
            Else
                $runNext = 1
            EndIf
            
    EndSelect
Next

Func function1()
;code
EndFunc

Func function2()
;code
EndFunc

Func function3()
;code
EndFunc

Func function3()
;code
EndFunc

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Link to comment
Share on other sites

yes that nice

thank you!

Like this?

$runNext = 1

For $i = 1 To 64 Step +1
    Select 
        
        Case $runNext = 1
            If function1() Then
                $runNext = 1
            Else
                $runNext = 2
            EndIf
            
        Case $runNext = 2
            If function2() Then
                $runNext = 2
            Else
                $runNext = 3
            EndIf
            
        Case $runNext = 3
            If function3() Then
                $runNext = 3
            Else
                $runNext = 4
            EndIf
            
        Case $runNext = 4
            If function4() Then
                $runNext = 4
            Else
                $runNext = 1
            EndIf
            
    EndSelect
Next

Func function1()
;code
EndFunc

Func function2()
;code
EndFunc

Func function3()
;code
EndFunc

Func function3()
;code
EndFunc
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...