Defines a set of lines as executable program code.
Func
function code
EndFunc
Menu Location
Press:
- Catalog ([2nd] + 2 on 92/+/v200) to access the catalog menu
- F to scroll to the F section
- Use arrows to navigate to Func
Or type Func using the keyboard
This command works on all calculators.
4 bytes
This command is used at the beginning/end of a function to tell the calculator to interpret it as code. Without these commands at the start and end of a function, the interpreter will pass a syntax error. Note that unlike Programs, functions cannot write to the screen, so there can be no IO commands or Draw commands. In addition, you cannot edit global variables in Functions, so you have to declare a variable as local using Local before initializing them. However, the reason you may want to use functions instead of programs is that unlike programs, you can return a value from a function. You can either use the Return command, or the function will return whatever the last value was before you quit the function.
:test()
:Func
://code to run goes here
:EndFunc
Advanced Uses
Using the local and define commands, you can create local submethods in your programs. Assuming the following code is inside a program block already, the syntax would be:
:Local test
:Define test()=Func
://function code goes here
:EndFunc