TI-BASIC (calculators)

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

See also

External links

Navigation

  • Art and Cultures
    • Art (https://academickids.com/encyclopedia/index.php/Art)
    • Architecture (https://academickids.com/encyclopedia/index.php/Architecture)
    • Cultures (https://www.academickids.com/encyclopedia/index.php/Cultures)
    • Music (https://www.academickids.com/encyclopedia/index.php/Music)
    • Musical Instruments (http://academickids.com/encyclopedia/index.php/List_of_musical_instruments)
  • Biographies (http://www.academickids.com/encyclopedia/index.php/Biographies)
  • Clipart (http://www.academickids.com/encyclopedia/index.php/Clipart)
  • Geography (http://www.academickids.com/encyclopedia/index.php/Geography)
    • Countries of the World (http://www.academickids.com/encyclopedia/index.php/Countries)
    • Maps (http://www.academickids.com/encyclopedia/index.php/Maps)
    • Flags (http://www.academickids.com/encyclopedia/index.php/Flags)
    • Continents (http://www.academickids.com/encyclopedia/index.php/Continents)
  • History (http://www.academickids.com/encyclopedia/index.php/History)
    • Ancient Civilizations (http://www.academickids.com/encyclopedia/index.php/Ancient_Civilizations)
    • Industrial Revolution (http://www.academickids.com/encyclopedia/index.php/Industrial_Revolution)
    • Middle Ages (http://www.academickids.com/encyclopedia/index.php/Middle_Ages)
    • Prehistory (http://www.academickids.com/encyclopedia/index.php/Prehistory)
    • Renaissance (http://www.academickids.com/encyclopedia/index.php/Renaissance)
    • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
    • United States (http://www.academickids.com/encyclopedia/index.php/United_States)
    • Wars (http://www.academickids.com/encyclopedia/index.php/Wars)
    • World History (http://www.academickids.com/encyclopedia/index.php/History_of_the_world)
  • Human Body (http://www.academickids.com/encyclopedia/index.php/Human_Body)
  • Mathematics (http://www.academickids.com/encyclopedia/index.php/Mathematics)
  • Reference (http://www.academickids.com/encyclopedia/index.php/Reference)
  • Science (http://www.academickids.com/encyclopedia/index.php/Science)
    • Animals (http://www.academickids.com/encyclopedia/index.php/Animals)
    • Aviation (http://www.academickids.com/encyclopedia/index.php/Aviation)
    • Dinosaurs (http://www.academickids.com/encyclopedia/index.php/Dinosaurs)
    • Earth (http://www.academickids.com/encyclopedia/index.php/Earth)
    • Inventions (http://www.academickids.com/encyclopedia/index.php/Inventions)
    • Physical Science (http://www.academickids.com/encyclopedia/index.php/Physical_Science)
    • Plants (http://www.academickids.com/encyclopedia/index.php/Plants)
    • Scientists (http://www.academickids.com/encyclopedia/index.php/Scientists)
  • Social Studies (http://www.academickids.com/encyclopedia/index.php/Social_Studies)
    • Anthropology (http://www.academickids.com/encyclopedia/index.php/Anthropology)
    • Economics (http://www.academickids.com/encyclopedia/index.php/Economics)
    • Government (http://www.academickids.com/encyclopedia/index.php/Government)
    • Religion (http://www.academickids.com/encyclopedia/index.php/Religion)
    • Holidays (http://www.academickids.com/encyclopedia/index.php/Holidays)
  • Space and Astronomy
    • Solar System (http://www.academickids.com/encyclopedia/index.php/Solar_System)
    • Planets (http://www.academickids.com/encyclopedia/index.php/Planets)
  • Sports (http://www.academickids.com/encyclopedia/index.php/Sports)
  • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
  • Weather (http://www.academickids.com/encyclopedia/index.php/Weather)
  • US States (http://www.academickids.com/encyclopedia/index.php/US_States)

Information

  • Home Page (http://academickids.com/encyclopedia/index.php)
  • Contact Us (http://www.academickids.com/encyclopedia/index.php/Contactus)

  • Clip Art (http://classroomclipart.com)
Toolbox
Personal tools