Warning
You're browsing the old v2.x documentation. This version is no longer maintained. Click here to go the v3.x documentation.
Table of Contents
Functions
Functions in XC=BASIC are procedures that return a value of a certain type.
XC=BASIC supports:
- Several built-in functions
- The USR() function to call a machine language function
- User-defined functions (since version 2.2)
Calling overloaded functions
Some of the built-in functions are overloaded and thus they may return values of miscellaneous types. When calling a function, you must explicitly specify which type you wish to call by appending the right sigil to the function name. For example, the ABS function can return an integer or a float:
myInt = abs(-5) myFloat%= abs%(-3.14)
Another example is RND that can return three different types:
myRandomByte! = rnd!() myRandomInt = rnd() myRandomFloat% = rnd%()
Note: user defined functions may not be overloaded.
Defining user functions
Please refer to the FUN ... ENDFUN directive for details.