Science Fair Project Encyclopedia
- This article is about the calculator programming language. For the TI 99/4A home computer programming language, see TI BASIC (TI 99/4A) (note: no hyphen between "TI" and "BASIC" in that version).
TI-BASIC is the unofficial name of a BASIC-like language built into Texas Instruments graphing calculators (TI only refers to it as the calculators' "extensive programming capability"). This is the simplest way to program any TI calculator although assembly language may also be used (most often Z80 assembly). On the TI-89 and higher calculators (with a Motorola 68000 processor) you can also use C, through a compiler called TIGCC. Although TI-BASIC is considerably slower than C or assembler and consequently is not much good for programming fast applications and games, it is very useful for quickly writing programs to solve math problems.
Examples of TI-BASIC
(for the Z80-based models)
The following program, when run, will clear the screen and print the words "HELLO WORLD":
:ClrHome :Disp "HELLO WORLD"
The next program will add the integers from 1 to 20 inclusive, and store the result to variable "A". It will then display the contents of A on a blank screen:
:Clrhome :0->A :For X,1,20 :A+X->A :End :Disp A
This one will tell the user the numerical value of any button pressed except the 'on' key, and will continue to loop until the calculator is turned off.
:ClrHome :Lbl 1 :getKey A :While A=0 :getKey A :End :ClrHome :Disp A :Goto 1
A common feature of TI-BASIC game programming is programming the arrow buttons to move an object on the screen. This program will draw a dot on on the screen that will move according to which arrow buttons you press.
:ClrDraw :-47 -> Xmin :47 -> Xmax :-31 -> Ymin :31 -> Ymax :0 -> X :0 -> Y :Lbl 1 :Pt-Off(X,Y) :getKey -> C :If C = 24 :X-1 -> X :If C = 25 :Y+1 -> Y :If C = 26 :X+1 -> X :If C = 34 :Y-1 -> Y :Pt-On(X,Y) :Goto 1
However, this code is both large and slow. Attempts have been made to optimize TI-Basic. The program below does the same thing as the program above, yet is far smaller, and possibly somewhat faster.
:ClrDraw :-47 -> Xmin :47 -> Xmax :-31 -> Ymin :31 -> Ymax :0 -> X :0 -> Y :Repeat 0 :Pt-Off(X,Y :getKey -> C :X+(C = 26)-(C = 24) -> X :Y+(C = 25)-(C = 34) -> Y :Pt-On(X,Y :End
The contents of this article is licensed from www.wikipedia.org under the GNU Free Documentation License. Click here to see the transparent copy and copyright details