|
We're glad you came by, but you might find what you're looking for elsewhere. TI-Basic Developer is not the site it once was. While its information on commands and other calculator features remains almost second-to-none, its forum, archives, and even hosting service, Wikidot, have been decaying for years. The calculator community would love to see what you're working on, or help you in your next coding adventure, but TI-Basic Developer is no longer the place to do it. Instead, you should head over to Cemetech (primarily American) or TI-Planet (primarily international). Both are active, well-established forums with their own archives, chatrooms, reference material, and abundant coding tools and resources. We'll see you there, we hope. |
Stores a value in a variable.
Define variable=value
Menu Location
Starting in the program editor:
- Press F4 to enter the Var menu.
- Press 1 or Enter to select Define.
This command works on all calculators.
2 bytes
The Define command sets the value of a variable. At its simplest, it's an alternative to →: Define x=5 is equivalent to 5→x. However, Define is also useful for defining functions or programs using Func..EndFunc or Prgm..EndPrgm respectively, which → can't do:
:Define key()=Func
: Local k
: Loop
: getKey()→k
: If k≠0
: Return k
: EndLoop
:EndFuncAdvanced Uses
Using Define to create functions or programs is very useful when inside a program. If your program uses its own subroutines to perform simple tasks (such as the key-reading program above), you can define these subroutines inside the program itself, keeping everything in one file (it might be good to make them Local or use DelVar to delete them afterwards). Subroutines are useful for organizing a large program.
Error Conditions
190 - Circular definition happens when defining a variable (other than a recursive function or program) in terms of itself.
