Passing a function as parameter in AutoIT

Viewed 4897

I have a few functions with the same structure (simplified):

func moveFiles()  
    local $error = 1  
        For $i = 1 to 100
            updateProgress($i)  
            updateStatus("Processing " & $i & "/100 files")  
            $error *= moveFile($i)  
        Next  
    Return $error  
endFunc  

I would like to make this a generic function like this:

func doSomething($function)  
    local $error = 1  
        For $i = 1 to 100
            updateProgress($i)  
            updateStatus("Processing " & $i & "/100 files")  

            $error *= $function($i)   ;execute the function that was passed

        Next  
    Return $error  
endFunc

So i can do like this:

doSomething($moveFiles)  
doSomething($compareFiles)
doSomething($removeFiles)
...

Is this possible in AutoIt v3 and how can i do it ?

1 Answers
Related