The Wayback Machine - https://web.archive.org/web/20120106051721/http://www.autoitscript.com:80/autoit3/udfs/UDF_Standards.htm

User Defined Functions Standards

This Page contains instructions on submitting UDF's for AutoIt3, it helps me if code is submitted following the below standards and include these 2 files::

  1. Catagory.au3 (the actual UDF in the proposed include filename)
  2. Functionname.au3 (the example script to be used in the helpfile)

You will appreciate that we can only include those UDF's that are useful to a larger group of scripter's.
When you still like your UDF to be included :-) then:

  1. Follow the below instructions for the files.
  2. Ensure your UDF is error free by running AU3Check with options:-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6.
  3. Ensure your UDF code is Tidy.
  4. Send me a PM or Email that contains the files in a zip file. (GaryFrost or "Gary at autoitscript dot com" ) .
  5. For those who wish to check the includes/templates: Build Templates Application

Thanks,
Gary

User Defined Function coding standards

Function Names
All function names must start with an underscore (“_”). *
Each word in the function name should be capitalized.
The first word of the function name should start with a word describing a general category such as “Date”, “String”, “Array”, “Network”, etc.. If the word is too long like “Window”, then an obvious abbreviation may be used (e.g. “Win” for “Window” or “Net” for “Network”).
All function names must closely resemble the established naming convention for "internal" AutoIt functions.

Variable Names
The first set of characters after the dollar sign (“$”) should be used to specify the type of data that will be held in it. The following list signifies the different prefixes and their data type significance.
$a<letter> - Array (the following letter describes the data type taken from the rest of the data types below)
$b - Binary data
$h - File or window handle
$i - Integer
$f - Boolean
$n - Floating point number
$s - String
$v - Variant (unknown/variable type of data)
The rest of the name uses capitalized words to describe the function of the variable. Names like “$iC” are unacceptable. "$aiWeekDayNames" or "$iCounter" are much preferable.
All variables must be declared at the beginning of the UDF with a “Local” scope and before they are used for the first time.
The “Dim” or “Global” keywords are ambiguous inside of a UDF and as such should be avoided, all variables should be transferred via the Function Parameters using Byref when the updated value needs to be returned.

Parameters
The parameter names must use the same naming conventions as variables.
All parameters must be checked for validity and return appropriate error codes.
If parameters are used to pass data back to the calling script (ByRef), then the documentation should explicitly describe said behavior.

Function Documentation
All UDFs must have a documentation header in the script in the following form:

; #FUNCTION# ;===============================================================================
;
; Name...........: _DateDiff
; Description ...: Returns the difference between 2 dates, expressed in the type requested
; Syntax.........: _DateDiff($sType, $sStartDate, $sEndDate)
; Parameters ....: $sType - One of the following:
; |D = Difference in days between the given dates
; |M = Difference in months between the given dates
; |Y = Difference in years between the given dates
; |w = Difference in Weeks between the given dates
; |h = Difference in hours between the given dates
; |n = Difference in minutes between the given dates
; |s = Difference in seconds between the given dates
; $sStartDate - Input Start date in the format "YYYY/MM/DD[ HH:MM:SS]"
; $sEndDate - Input End date in the format "YYYY/MM/DD[ HH:MM:SS]"
; Return values .: Success - Difference between the 2 dates.
; Failure - Returns 0 and Sets @Error:
; |0 - No error.
; |1 - Invalid $sType
; |2 - Invalid $sStartDate
; |3 - Invalid $sEndDate
; Author ........: Jos van der Zande
; Modified.......:
; Remarks .......:
; Related .......: _DateAdd
; Link ..........;
; Example .......; Yes
;
; ;==========================================================================================
Func _DateDiff($sType, $sStartDate, $sEndDate)
...

 

Function Helpfile Documentation

All submitted UDFs must include 1 extra file to be able to incorporate them in the Helpfile:

FunctionName.AU3. This is the example to be included in the Helpfile
(Example):

#include <Date.au3>

; Calculated the number of seconds since EPOCH (1970/01/01 00:00:00)
$iDateCalc = _DateDiff( 's',"1970/01/01 00:00:00",_NowCalc())
MsgBox( 4096, "", "Number of seconds since EPOCH: " & $iDateCalc )

; Calculated the number of Hours this year
$iDateCalc = _DateDiff( 'h',@YEAR & "/01/01 00:00:00",_NowCalc())
MsgBox( 4096, "", "Number of Hours this year: " & $iDateCalc )