AKD BASIC User Guide | 6 AKD BASIC Parameters, Operators, Statements
6.1.9 Function
General Information
Type Statement
Description
The Function statement is used to declare and define the name, arguments and
type of a user defined function.
Units N/A
Range N/A
Default
Value
N/A
Data Type N/A
Start Ver-
sion
TBD
Description
The Function statement is used to declare and define the name, arguments and type of a user
defined function. The code for the function immediately follows the function statement and
must be terminated by an End Function statement.
On entry to the function all local variables are initialized to zero including all elements of local
arrays. All local string variables are initialized to the null string ("").
If a function takes no arguments then the argument-list (including the parentheses) must be
omitted, both when declaring the function and when using the function.
The return value for the function is specified by making an assigment to the function name. See
the example (cube) below.
Arguments, including array arguments, are passed by value. Arrays cannot be returned from
functions.
Example
This example declares a function that calculates the cube of a floating point number.
Main
dim LocalFloat as float
LocalFloat = 1.234
LocalFloat = cube(LocalFloat)
print LocalFloat
End Main
Function cube( x as float) as float
cube = x ^3
End Function
Related Topics
Dim | Static | Exit | Sub...End Sub
Kollmorgenâ„¢ | March 30, 2012 106