Warning
You're browsing the old v2.x documentation. This version is no longer maintained. Click here to go the v3.x documentation.
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
functions [2019/05/06 10:07] – created neils | functions [2019/12/12 19:35] (current) – [Functions] neils | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Functions ====== | ====== Functions ====== | ||
- | XC=BASIC | + | Functions in **XC=BASIC** are procedures that return a value of a certain type. |
- | ===== Return type ===== | + | **XC=BASIC** supports: |
- | Some functions | + | * Several built-in |
+ | * The [[USR|USR() function]] to call a machine language function | ||
+ | * [[fun|User-defined functions]] (since version 2.2) | ||
- | myInt = ABS(-5) | ||
- | myFloat = ABS%(-3.14) | ||
+ | ===== 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 [[https:// | ||
+ | |||
+ | myInt = abs(-5) | ||
+ | myFloat%= abs%(-3.14) | ||
+ | |||
+ | Another example is [[RND|RND]] that can return three different types: | ||
+ | |||
+ | myRandomByte! | ||
+ | myRandomInt | ||
+ | myRandomFloat% = rnd%() | ||
+ | | ||
+ | Note: user defined functions may not be overloaded. | ||
+ | ===== Defining user functions ===== | ||
+ | |||
+ | Please refer to the [[fun|FUN ... ENDFUN]] directive for details. |