Functions

Functions in XC=BASIC are procedures that return a value of a certain type.

XC=BASIC supports:

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.