Func ... EndFunc Block

func.png

Command Summary

Defines a set of lines as executable program code.

Command Syntax

Func
function code
EndFunc

Menu Location

Press:

  1. Catalog ([2nd] + 2 on 92/+/v200) to access the catalog menu
  2. F to scroll to the F section
  3. Use arrows to navigate to Func

Or type Func using the keyboard

Calculator Compatibility

This command works on all calculators.

Token Size

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

Related Commands

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