【发布时间】:2012-07-23 14:31:33
【问题描述】:
我有几个具有相同结构的函数(简化):
func moveFiles()
local $error = 1
For $i = 1 to 100
updateProgress($i)
updateStatus("Processing " & $i & "/100 files")
$error *= moveFile($i)
Next
Return $error
endFunc
我想让它成为这样的通用函数:
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
所以我可以这样做:
doSomething($moveFiles)
doSomething($compareFiles)
doSomething($removeFiles)
...
这在 AutoIt v3 中是否可行?我该怎么做?
【问题讨论】:
标签: function generics parameters autoit