Original Author Paul Laughton, 2011
Page 78
De Re BASIC!
A function can return only a single scalar value. It cannot return an array. It cannot return a data
structure (List, Stack, Bundle, or graphical object), but it can return a pointer to a data structure.
Note: You can also return information to a function's caller through parameters passed by reference.
Fn.end
Ends the definition of a user-defined function. Every function definition must end with Fn.end.
When your function is running, executing the Fn.end statement causes the function to terminate and
return a default value. If the function type is numeric then the default return value is 0.0. A string
function returns the empty string ("").
Call <user_defined_function>
Executes the user-defined function. Any value returned by the function will be discarded.
The CALL command keyword is optional. Just as BASIC! can infer the LET command from a line that
starts with a variable, it can infer the CALL command from a line that starts with a function name.
For example, if you have defined a function like this:
FN.DEF MyFunction(x, y$, z)
< your code here >
FN.END
You can execute the function, ignoring its return value, with either of these statements:
CALL MyFunction(a, b$, c)
MyFunction(a, b$, c)
As with LET, you must use CALL if your function name starts with a BASIC! command keyword. It is also a
little faster to execute a function with CALL than to make BASIC! infer the command. See LET, above, for
details.
Program Control Commands
If / Then / Else / Elseif / Endif
The If commands provide for the conditional execution of blocks of statements. (Note: the braces { } are
not part of the command syntax. They are used only to show parts that are optional.)
IF <condition> { THEN }
<statement>
<statement>
...
<statement>
{ ELSEIF<condition> { THEN }
<statement>
<statement>