Keyword Reference


Specifies that the current file should only be included once.



It is quite common to have the same "#include <filename.au3>" line in several of the files included included in a script. If the same file were to be included several times, it is quite likely that this would generate a "Duplicate function" or "Cannot redeclare a Const" error. So when writing a script intended for use as an include file, add #include-once to prevent that file from being included more than once. Note that the #include-once line must be placed at the top of the script and before any other #include lines.

It is not recommended to add a #include-once line to scripts which are not intended to be used as include files within other scripts.




; Use #include-once when creating UDFs so the file isn't included multiple times
; if you call the same UDF in multiple files.

#include <MsgBoxConstants.au3>

; Rename this file as IncludeFunc.au3 and place next to the main script.
; Then add #include "IncludeFunc.au3" at the top of the script.

Func IncludeFunc()
    MsgBox($MB_SYSTEMMODAL, "", "This is an example of including a file.")
EndFunc   ;==>IncludeFunc