Development Topics > BASIC Extensions > A-Shell Extensions > User-defined Functions
Function Name and Type

Reviewed May 2009

The function name must begin with FN' (case insensitive). A side effect of this rule is that you may not define an array with a name starting with FN'.

Like other Basic expressions, functions fall into two fundamental types: numeric and string / unformatted. So that the compiler can immediately recognize the type of the function when it is referenced before being defined (without requiring forward declarations), the following naming convention is required:

• Functions that return string (or unformatted or structure) values must have names that end in $, such as Fn'Format$(...)

• Functions that return numeric values must have names that do not end in $, such as Fn'Average(...)

The return type can be further refined by appending the "as <typsiz>" clause to the end of the Function declaration (as in the Examples). Note, however, that you cannot override the rule just stated regarding the requirement that the names of functions returning string or unformatted values must end in $, while those returning numeric values must not end in $. If no "as <typsiz>" clause is specified, the standard defaults for implicit mapping of variables will determine the return type (i.e. F,6 for numeric functions, and S,# where # is 10 or the current STRSIZ for string functions.