# Function Notes

Many functions contain optional parameters that can be omitted. If you wish to specify an optional parameter, however, all preceding parameters must be specified!
For example, consider Run ( "filename", ["workingdir" [, flag]] ). If you wish to specify the flag, you must specify a workingdir.
Many Win___ functions contain an optional parameter "text". This parameter is intended to help differentiate between windows that have identical titles.
Some functions 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 someUserFunc() then ;...function worked
If Not someUserFunc() then ;...function failed
$x = FileReadLine("C:\someFile.txt")
If @error = -1 Then ;end-of-file was reached
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...

@error is always set to 0 when entering in a function.

When the documentation states that the return value = none, AutoIt always returns a value to avoid errors. 1 is usually the value returned, but you should not depend on this return value.

When an optional parameter needs to be defined and is preceded by one or more optional parameters, the default value must be given. This may be "" for a string parameter and -1 for other types. Some functions like StringInStr or StringReplace require 0. See the corresponding optional parameter description.