68k Functions

Introduction

The 68k series can easily make a accurate distinction between programs and/or functions. Functions are just like programs except that they do not allow statements with side effects (such as Input or "Disp," or allow editing of non-local variables), and they return a single value, which in the absence of an explicit Return statement is the last expression evaluated in the system.

Moreover, the 68k version of TI-BASIC allows creating user-defined functions. Functions have the same syntax as programs except that they use the "Func…EndFunc" keywords instead of "Prgm…EndPrgm," and that they are not allowed to use instructions that perform I/O, modify non-local variables, nor call programs. However, functions can still be non-pure because they can call built-in functions such as "getTime(), getKey(), or rand()."

Lastly, all functions have a return value, which in the absence of an explicit Return statement is the last expression evaluated.

Functions Program Example

fact(x)
:Func
:If x=0
:Return 1
:If x<0
:Return undef
:x*fact(x-1)
:End Func

Bibliography

To learn more about 68k BASIC, check out the link below:
https://en.wikipedia.org/wiki/TI-BASIC

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Noncommercial-No Derivative Works 2.5 License.