TI-Basic
TI-Basic is the name of a programming language used by programmable pocket calculators from the American company Texas Instruments (TI). It differs somewhat from the popular BASIC programming language . Especially for the newer models from Texas Instruments, such as the TI-83 Plus or the TI-83 Plus SE , the TI-84 Plus , the TI-89 , the TI-92 or TI-92 Plus , the Voyage 200 and the TI-Nspire there are a variety of programs today.
General
Programs and functions
Both programs and functions can be created with TI-Basic . The difference is that, in contrast to programs, functions return
can return values using the command , but all other input and output commands (input, output, PxlOn, etc.) can only be used in programs. Furthermore, it is not possible for a function to permanently save variables in the global namespace, but only temporarily and locally, as long as the function is being executed.
variables
Compared to many other programming languages, the number of possible variable names is very limited. With the exception of the TI-Nspire, it is only possible to use names that have eight or fewer letters (in the TI-BASIC dialect of the TI-84 and TI-83 even only one letter) and not the same name as a system variable (for example Y 1 ). A value is usually assigned to a variable using the "→" operator (syntax: value → variable ). A variable is always global and can be read or edited by all programs. Even after a program has ended, the variables are retained unless they are explicitly deleted.
programming
In addition to direct input on the TI, the programs can also be edited externally on the computer and then transferred to the TI via data cable.
Conditions (all calculators above)
- If statement (without Then, only the next command counts for the If statement):
- If condition
- Disp "condition fulfilled"
- Disp "This statement is always executed"
- If ... Then ... EndIf statements:
- If condition Then
- Disp "These instructions are"
- Disp "all only executed"
- Disp "if the condition is met"
- EndIf
- Disp "This statement is always executed"
- If ... Then ... Else ... EndIf statements:
- If condition Then
- (multiple instructions)
- Else
- (several statements that are only executed if the condition is not met)
- EndIf
grind
All of the above calculators
TI-Basic can handle the following types of loops: the For loop with counter variable and the While loop , which is executed as long as the condition is true. In addition, loops can be created using labels .
Loop style | use | example |
---|---|---|
For | : For variable , start , end [, step size ] : Commands : EndFor |
: For X, 0,10,2 : Disp X : EndFor |
While | : While expression : Commands as long as condition is true : EndWhile |
: While X <5 : X + 1 → X : EndWhile |
Label | : Lbl label name : Commands : Goto label name |
: Lbl A : X + 1 → X : Goto A |
TI-89, TI Voyage 200, and TI-Nspire
The TI-89, the TI Voyage 200 and the TI-Nspire are still available Loop
and EndLoop
as an endless loop. You can - like While
and EndWhile
and For
and EndFor
- Exit
cancel it with the command .
Loop style | use | example |
---|---|---|
Loop |
:Loop : Block :EndLoop
|
: 0 → I : Loop : I + 1 → I : Disp I : If I = 10 : Exit : EndLoop |
TI-83 Plus; TI-83 Plus SE; TI-84 Plus
variables
The following variables can be used with these computers:
Variable type | Variable names | Example of an assignment | Limitations |
---|---|---|---|
Real numbers | AZ, θ | 10 → X | Up to 14 digits are stored, but only ten digits are output |
Complex numbers | AZ, θ | 5 + 7i → Y | Up to 14 digits are stored, but only ten digits are output |
Strings | Str0 – Str9 | "TEXT" → Str2 | The amount of free RAM is the only length limit |
Lists | L1 – L6, user-defined | {1,2,3} → L LIST | Up to 999 elements can be saved (exception TI-83: up to 99 elements) |
Matrices | [A] - [J] | [[1,2,3] [4,5,6]] → [C] | A matrix can have up to 99 rows and 99 columns |
Graphics | Pic0-Pic9 | StorePic 5 | Display resolution: Images cannot be larger than 96 × 64 pixels |
Math functions | Y 0 -Y 9 | "6X² + 7X-2" → Y 8 | No known limit |
Graph databases | GDB0-GDB9 | StoreGDB 0 | No known limit |
Scales for graphs | X min , X max , X scl , X res , ∆X (analogous for the Y-axis) | 5 → X min | No known limit |
Repeat loop
Another type of loop can only be used on these computers:
Repeat | : Repeat Expression : Commands until condition is true : End |
: Repeat I <5 : I-1 → I : End |
IS>; DS <and menu
These instructions are also no longer available on the newer computers.
Type of branch | use | example |
---|---|---|
Increase step | : IS> ( variable , value ) : Command if value ≥ variable |
: IS> (A, 3) : Disp A |
Decrease step | : DS <( variable , value ) : Command if value ≤ variable |
: DS <(A, 3) : Disp A |
Menu | : Menu (" Description" , "Text 1" , Label 1 , "Text 2" , Label 2 , ...) |
: Menu ("OPTIONS", "START", A, "EXIT", B) |
Newer computers (TI-89 through Voyage 200)
variables
On newer computers, variables can be a maximum of eight characters long; umlauts, Greek letters and diacritical marks (in contrast to some other programming languages such as Pascal ) can also be used. "StorePic" and "StoreGDB" have been replaced by "StoPic" and "StoGDB".
Menus, dialogs and toolbar
In addition to the Input and InputStr prompts , the user interface can be implemented as follows:
- with dialog blocks
- with popup menus
- using the toolbar (toolbar or custom)
- with the getKey () function
dialog
An example of a dialogue:
- dialog
- Title "Hello"
- Text "xyz"
- Dropdown "Please select", {"One", "Two", "Three"}, var1
- Request "your name?", Var2
- EndDlog
This example creates a dialog with the title "Hello". The actual window contains the text "xyz", underneath you can choose between "one", "two" and "three", and at the very bottom there is an input field where the user is asked for his name.
The screenshot on the right shows this example program.
PopUp
An example of a screen pop:
- PopUp {"1999", "2001", "2002", "2005"}, var3
The result, i.e. the selection, is saved in the variable "var3". For example "2001" the content of var3 would be the number 2.
On the right is the screenshot for this program, only the Disp
command has been added.
Toolbar
An example of a toolbar:
- Toolbar
- Title "start quiz", start
- Title "Options"
- "Settings" item, options
- Item "About this quiz ...", about
- Title "Quit", quit
- EndTBar
If you select F1 (start quiz) (here in this example), the program jumps to the specified label "start". If you want to list more under a title (as in F2), Title
no label may be specified after the command. In such a case, however, Item
s with labels must be present under the title command .
On the right is also a screenshot showing the toolbar. Only one Output
command has been added again.
TI-Nspire and TI-Nspire CAS
In the first version of the operating system of the TI-Nspire and TI-Nspire CAS computers, only functions could be created with TI-Basic , not programs . In the meantime, an extended range of commands is available, but it does not contain numerous TI Basic commands, e.g. for dialog guidance. Programs can be stored in libraries.
Hello World
- ClrHome Clears all characters on the display
- Disp "Hello World" then shows "Hello World"
Or:
- ClrHome Clears all characters on the display
- Output (1,1, "Hello World") Shows "Hello World" in the first row in the first column
For TI-Nspire CX CAS:
- Disp "Hello World" shows "Hello World" in the "Home window"
Efficiency
Compared to the 68k assembler integrated in the computer, TI basic programs are very slow. Output commands in particular slow down the execution, and due to the small amount of RAM memory, recursions such as the Ackermann function can only be implemented to a limited extent or not at all, neither with TI-BASIC nor with assembler.