User Defined Function Notes

We have included number of files that each contain standard AutoIt3 Functions, so called User Defined Functions.
UDF's are functions/Scriptlets, written in AutoIt3, you can #include in your own script and use them without the need to program it yourself or Copy&Paste them every time you need them.


#include <Date.au3>
#include <MsgBoxConstants.au3>

MsgBox($MB_SYSTEMMODAL, "What is the date?", "Today's date is " & _Now())

This script will display today's date formatted in your pc's long format. e.g. "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 parameter is preceded with ByRef this means 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...