Please enable JavaScript to view this site.

A-Shell Consolidated Reference

Updated October 2014

The function name must begin with FN' and is case insensitive. (Changed; see History, below). 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.

History

2014 October, A-Shell 6.1.1391:  Compiler enhancement (edit 708): when the /P (or -p) switch is used, it is no longer required that function names start with fn'. The main downside of taking advantage of this option is that it could make your source code harder to understand, since it wouldn't be immediately clear whether a subscripted identifier appearing in an expression, e.g.

something = WhatIsThis(idx)

is an array reference or a function reference. The compiler can tell the difference though. The upside is mainly aesthetic, allowing you to syntactically simplify your functions. This could be particularly helpful in cases where you have class-like collections of related functions and procedures. These can all share a common prefix, allowing you to adopt a simpler but more object-oriented syntax scheme, i.e. object.verb(params).

Note: This feature is under review and should only be used with caution.