用户自定义函数说明

我们有很多包含了标准 AutoIt3 函数的文件, 我们叫它 User Defined Functions(用户定义的函数).
UDF 是一些函数/脚本片段, 使用 AutoIt3 编写, 您可以包含(#include)它们到您自己的脚本中并使用它们.在需要它们时,不需要程序自己或者每次手动复制&粘贴代码.

例子:

#include <Date.au3>

MsgBox(0, "今天是哪天?", "今天是 " & _Now())

这个脚本将会显示按计算机长格式格式化后的当前日期. 例如: "Sunday, December 18, 2004"

 

Many UDF's contain optional parameters that can be omitted. If you wish to specify an optional parameter, however, all parameters that precede it must be specified!
For example, consider _ArraySort ( ByRef $a_Array [, $i_Descending [, $i_Base=0 [, $i_Ubound=0 [, $i_Dim=1 [, $i_SortIndex=0 ]]]]] )
When a parameters is preceded with Byref mean that the function will update this variable with a new value. These parameters must be a variable ($xyz) and cannot be a constant.

Most UDF's indicate success/failure as a return value; others indicate it by setting the @error flag. Some do both....
@error = 0 ;is always success
Return = varies, but is typically non-zero for success to allow easy to read code...

If a function can set the @error flag, you should always check it before using a return value - if @error indicates an error then the function return value is generally undefined...