Please enable JavaScript to view this site.

A-Shell Development History

Navigation: Version 4.9/5.0, builds 850-998 > 977 - 28 Dec 06

Function / Procedure Definitions

Scroll Prev Top Next More

Compiler now supports the ability to specify explicit types and sizes for parameters in function and procedure definitions, as well as the function return type/size, as in this example:

Function fn'x(var1, var2 as s100, var3 as b1) as i4

   <function body>

End Function

 

Each parameter, as well as the function itself, allows an optional "as <type><size>" clause to override the implicit type and size that would otherwise be assigned per the normal implicit rules.

In the example above, var1 will be assigned the default numeric type (F8); var2 will be allocated as a 100 byte string, and var3 as a 1 byte binary. The function itself will return a 4 byte integer value.

The allowed types and sizes are the same as for map statements, except that there is no comma between the type code and the size digits.

Note that although individual parameters do not have to conform to the implicit rule of using $ to indicate string variables, the function itself does. So in the example above, we can override the default type of F8 for the function fn'x(), but only as long as we stick with numeric types (F,B,I). In order to use a string type, we would still have to name the function with a $ suffix, i.e. fn'x$(). (In this case, the main point is to be able to override the default string size.)