TI Basic is one of the languages that can be used to program Texas Instruments programmable calculators. It is built in to the calculator, and thus doesn't require a computer, as I believe Z80 (or whichever chip is in your particular TI calculator) Assembly language programming does. It is very much like BASIC in its style and structure, and thus is quite simple to learn.

Anyway, I'm no TI or Basic guru, so I'll leave it to someone more knowledgeable to make a better overview-type writeup. Instead, I thought I'd share a couple of programs I wrote back in grade 12, so that others might make use of them. (Notes on notation and such are below.)

Quadratic Roots Formula

ClrHome
Prompt A
Prompt B
Prompt C
((-B)/(2A))+(sqrt(B2-4AC)/(2A))->P
((-B)/(2A))-(sqrt(B2-4AC)/(2A))->Q
Disp "X=",P,Q
The above program will solve an equation of the form Ax2 + Bx + C = 0 for x by the quadratic roots formula. It prompts for A, then B, then C, and spits out the answer.

Summation

Input "UPPER LIMIT=",N
Input "INITIAL VALUE=",K
Input "INCREMENT=",J
Input "FUNCTION OF X=",Str1
String>Equ(Str1,Y0)
0->A
For(I,K,N,J)
I->X
Y0+A->A
End
Disp A

This program will calculate the summation of some one-variable function (X must be the variable) entered by the user over a given interval, with a given increment.

Notes:
Instead of the square root symbol, I've used sqrt(. In the program, you should of course use the square root sign.
-> denotes the store character (the button marked STO> on the TI-83).
The functions used in the programs should be listed in the index of your manual; if you don't have one and don't know where to find a function or variable name you need, hit the Catalog function (2nd + 0 on a TI-83), and scroll down until you find it. If you need any help, /msg me. :)
TI BASIC noded functions:

-ClrHome
-ClrIO
-Output

TI BASIC noded programs:

-TI-89 Matrix
-TI Basic

TI BASIC noded tutorials:

-Animation on TI Calculators
/msg Nanosecond with additions.
I am frightened. Absolutely frightened at the mention of that...that...curse of a 'language' known as TI-BASIC. I was first introduced to programming on a TI-81. Do you realize how many commands this impotent thing had!?! Here are all the control expressions:
Lbl
Goto
If
Pause
Stop
End
That's right, there wasn't even a built in If-Then-Else control. When if evaluated true, it executed the next line; otherwise it skipped the next line. This meant that if you wanted to execute more than one instruction when something was true, you had to use a goto...or a subroutine, except you were limited to a total of 36 subroutines/programs. That is, if you could fit it in the 2.4 KB of available memory. Worse still, you were limited to a total of 27 variables, and variables were global across all subroutines!

Obviously, this would be perceived as some sort of challenge to an experienced programmer. A place where your goto instincts can finally be excercised freely. But remember, I was learning to program on this thing. And we're not just talking about pathetic quadratic equation solvers here, no! I wrote a fully functional blackjack and was insane enough to attempt poker!

Fortunately, a friend of my mother's later gave me a TI-82. Now this thing was the real deal. It had just about every control structure that the modern TI-83 features. Everything from For and While, If, Then and Else and the ability to communicate between two connected calculators. I wrote the bane of all geometry teachers in the now infamous Crashcourse program (which was coded during Freshman speech). I even wrote an unbeatable Tic-Tac-Toe program during a series of particularly boring Chemistry lectures (Sophomore Year) but this was less popular...seeing as you couldn't win. I also discovered the incredible archive available at ticalc.org. Apparently, some ingenious hacker figured out a way to use direct, assembly level programming on the TI-82's 6 MHz ZiLOG Z80. This led me to distribute much more sinister programs - ie Final Fantasy IV - throughout the unsuspecting Jenifer Junior High.

The only problem I found with the programs available at ticalc.org was that their math programs almost always lacked documenation, were non-intuitive and often were inaccurate. So, I was forced to write my own. My programs in 8th Grade Algebra literally could have done the entire test, without error. My 9th Grade Geometry system could do everything but the proofs...and had all the important theorems typed in, just in case. This tradition continued up until the second semester of 10th Grade, when I inherited my sister's TI-92. Needless to say, I no longer needed to write any programs when I had a fully featured computer algebra system at my finger tips. This was quite fortunate, by that point I had maxed out the TI-82's 28K of RAM with math programs alone.

Interestingly enough, most of my teachers didn't care if I used a program, so long as I had written it. They did object, however, to me distributing them throughout the programming illiterate population. This problem was solved in a manner very similar to ticalc.org's policy. I was a beginning programmer, what the hell was a UI? I knew that A stood for degrees in the opposite angle, that's all that was important!

So, yes, I look back on TI-BASIC with initial agony...but with a degree of fondness as well. Let's just say it was a bit of a shock when I first tried to move from TI-BASIC to C++...

TI-Basic is the on-board interpreted programming language for graphing calculators made by Texas Instruments. TI-Basic, as implemented on all TI calculators prior to the TI-89, is designed for quick calculations that the user has, for some reason, decided it is best to create a program for. (This is most frequently because the program represents operations that would be frequently used, or the calculation is best executed iteratively or recursively.) This language is quite suitable for tasks such as this, but it was never designed for the impressive uses many programmers have put the language to.

TI-Basic, as implemented on the earlier calculators, has very few control flow expressions. It uses BASIC-style verbose keywords for command blocks, and the earliest forms of TI-Basic do not have blocks of any form, requiring if statements to refer to goto statements should one wish for multiple operations to be executed, and loops must be manually built by use of if and goto. These inadequacies in the language force any significant programming project within the language to become spaghetti code. This form of TI-Basic does not support comments.

The TI-89, and later models of calculator, had a greatly improved form of TI-Basic. On the Voyage 200, with its built-in QWERTY keyboard, it becomes quite feasible to write more complicated programs. Although it retains the bulky "if...then...endif", "for...endfor", and "while...endwhile" syntax of previous forms of the language, it makes great strides in other areas. The most notable improvements are local variables that cannot conflict with previously-existing data, local functions, and indeed the notion of a user-defined function that can return a value at all, so such algorithms can call each other and use each other's output directly, rather than previous forms of TI-Basic which, although they support calling other programs, cannot return values. (Many programmers dodged this obstacle by defining a variable "RET", or some other standard name, that a subroutine's output was placed into where the calling program could read it.) This version of TI-Basic also adds comment functionality.

TI-Basic as implemented on the TI-89, TI-92+, and Voyage 200 is far superior to the language on previous calculators and should be considered a different language. However, the language is still interpreted rather than compiled, and therefore executes extremely slowly compared to programs written in assembly language or, more recently, C, with the assistance of the TIGCC compiler and IDE.

The greatest saving grace for TI-Basic is that it allows programs, of any form, to be written on the calculator without the assistance of a computer. Typing on a calculator keyboard is, however, inconvenient, with the notable exceptions of the TI-92, TI-92+, and Voyage 200, all of which sport QWERTY keyboards. As typing on such a device is inherently slow and bulky anyway, it is unreasonable to expect anything large to be programmed in the language; as a tool to automate repetitious or frequently-used calculations, it does its job just fine.

The Basics

Calculator programming is easy once you learn what each function does.
Here is a list of functions and what you need to do to...uhh...make them work.

Examples are shown underneath in italics
{Brackets show actual code}

Input

• Input - The format for this is to put a title in quotes followed by ", variable". This will produce a line like the one below
{Input "Number of Apples:", A} shows "Number of Apples:" on the screen and stores the inputted number of apples into variable A
Or just put a variable for simply saving an input number into the variable
{Input A} creates a line "?" and the inputted number is stored to A

• Prompt - Enter the name of a variable to create a line like "variable=?" for input
{Prompt A} creates the line "A=?" and the input is stored to A

• getKey - The 'button code' of the last key pressed is returned. If no key is pressed getKey = 0; The button code is a 2 or 3 digit number, a combination of two different numbers; the first is the row it's in, the second is the column it's in.
Essential for game-making.
Button code for the 2nd key (2nd row, 1st button) = 21 on most Ti calculators

• Rcl - Recall - Imports the number value, picture, program lines, etc. of the specified target

• RcGDB - Recalls graph data already saved (save by using StGDB when on the y= screen; you need to put a DispGraph function after this

• RcPic - Recalls screenshots to the graph window (save screenshots with the StPic function on graph window); you do not need to put a DispGraph function after this

• InpSt - Some calculators have this, this allows words or letters to be stored into a variable

• The key STO-> creates an arrow on the screen, any number on the left side of the arrow will be stored to any variable on the right
{5 -> A} stores 5 to variable A

Output

• Disp - The simplest output function, used to recall variables or print words onto the screen
Each Disp command forms a new line.
Follow with a variable or something in quotes
{Disp A} displays the value assigned to A on the right side of the screen
{Disp "HEY!"} displays the word HEY! on the left side of the screen

• Output( - A more sophisticated version of Disp; Requires 2 numbers for position and then has a simple Disp command
Variable outputs need to be closed with parentheses ')'; text outputs do not or won't work if they are
{Output(3,4,A)} will display the number assigned to A in the 3rd row from the top and the 4th row from the left
{Output(3,4,"BOOM!"} will display BOOM! in the 3rd row from the top and the 4th row from the left

• DispGraph - This function shows the graph window where graphs or pictures can be displayed

• ClrHome/ClLCD - This clears the main screen (where you actually use the calculator...as a calculator)

• ClearDraw - Clears the graph window except for y= functions, which will be redrawn automatically, against your will

The following functions can be found under the Draw menu, they obviously draw on the graph window based on given information

• Line( - Simply supply the coordinates of 2 points and a line will be drawn between them
{Line(3,4,7,8)} will draw a line from a point with coordinates (3,4) to a point with coordinates (7,8)

• dot( - Draws a point at specified coordinates...as if you couldn't figured that out on your own
{dot(5,6)} draws a point at coordinated (5,6)...whoopee...

• PtOn( - the exact same thing as the aforementioned dot( function

• PtOff( - the exact same thing as the aforementioned PtOn( function, except it removes a point from that spot

• PtChg( - whoa...déjà vu all over again...The EXACT SAME THING as the previous 3 functions only it draws a dot if there isn't one there OR erases one if there is one there

• Shade( - Add two y coordinates to shade an area
• smaller number first: The Eternal Blackness of Death and Despair!
• larger number first: The Unexciting Parallel Lines...of Death and Despair!

{Shade(-10,10)} fills the area between 10 on the graph screen and -10 with black
{Shade(10,-10)} creates two parallel lines, one at 10 on the graph screen and one at -10

You can also shade boxes by using the first two parameters as normal but adding 2 more for edge limits

{Shade(-10,10,-5,5)} will shade between 10 and -10 vertcally and 5 and -5 horizantally

• Vert( - Only one number needed: x coordinate. Draws a vertical line at specified x coordinate

• Circle( - Three numbers needed: coordinates and radius.
{Circle(8,3,1.5) draws a circle with its center at (8,3) and with a radius of 1.5

• DrawF - Graphs a function in terms of X
{DrawF Y1} {DrawF Y1 - 5} draws the function assigned to Y1 only 5 Y's lower
(directly from the manual)Note: You cannot use a list in expression to draw a family of curves

• DrawInv - Graphs the inverse of a function
{DrawInv Y1} draws the inverse of Y1

Use the following functions to alter the graph window

• AxesOff - Removes the x and y axes from the graph window

• AxesOn - Displays the x and y axes on the graph window

• Zoom - Oh boy...There are several different Zoom settings each changing the area shown on the graph screen:
• Box - Allows you to draw a square to set the new viewing area

• Decimal - Sets the screen to view from -1 to 1 on both the x and y axes

• Integer - Sets the screen to view from 1 to 10 on both the x and y axes

• Fit - Readjusts the Y max and min to show the highest and lowest values between the current X max and min

• Previous - Returns to the last zoom setting

• Stat - Readjusts the window to show all statistical points

• Square - Adjusts the screen so that each x and y are intervaled equally; circles are actually circles and squares actually squares

• Standard - Sets the screen to view from -10 to 10 on both the x and y axes

• ZoomSto - Stores the current zoom setting

• ZoomRCL - Recalls the stored zoom setting

• Zoom In - Magnifies the area around the cursor to show more detail

• Zoom Out - Widens the current viewing area

Of course you can always set the window manually by using the Window screen. The Min value is the lowest value displayed on that axis(X-Min, Y-Min). The Max value is the highest value displayed on that axis(X-Max, Y-Max).

Control

These are the commandos. These bad boys give the orders mercilessly and only obey you. They can tend to make you feel real important. They can also drive you absolutely crazy

Here is the list of s for nearly every control function

• = or = = - equal to

• =/= - not equal to

• < - less than

• > - greater than

• < - less than or equal to

• > - greater than or equal to

• % - divides by a number and tests if the remainder equals 0
{A%5} - divides A by 5 and tests to see if the remainder is 0

Okay, now that that's over with, here are the commandos:

• End - closes a control function, essential for If-Then statements, For functions, and While commands. Please note that some Ti calculators have specific end functions for specific functions. Known examples: Ti-89, endif, endfor, and endwhile. Just use these according to syntax in place of a regular End function.

• Pause - Pauses the program until Enter is pressed

• Stop - Exits the program

• If( - A simple function that completes the immediately following line if the logical test is true.
'= =' works better than '=', in fact {If (blah)=(bleh)} is sometimes read as {If(blah)=/=(bleh)}
{If A=5
Disp "A=5"}
This simple two line command checks to see if A is equal to 5, if it is it displays A=5, if not, it skips the following line (Disp "A=5") and continues the program

• Then - For more advanced If commands; Else command is needed to make this work also. The If function runs and if the logical test is true, it performs all the commands under Then, if not, it performs all the commands under Else.
Closed with an End command
{Prompt A
If A= =5
Then
Disp "A=5"
Stop
Else
Disp "A≠5"
Stop
End}
This program tests A=5 then performs accordingly; this program in complete and can be put directly into your calculator for testing

• Else - See Then

• For( - For is a loop function. It loops a specified amount of times. End is required for loop to work
For(variable,# for variable to start on,# for variable to end on,increment)
{For(A,1,5,1)
command
End}
This will repeat the command 5 times

• While - This is another looping function, it works like the If function. End is required for to work
While logical test
{While 1} produces an infinite loop

{While A<56
Disp A
A+1->A
End}

This program counts to 55. And now for my famous, infinitely counting program:
{1 -> A
While 1
Disp A
A+1->A
End}

"WHY CAN'T IS STOP THIS THING?!"? - Press the ON button, no memory will be erased, relax

• Repeat - This repeats until the logical test is true or while it is false
I guess the infinite loop for this would be {Repeat 1= =1} or any similar function {1->A
Repeat A>5
Disp A
A+1->A
End}
This simple program counts until A is greater than 5, or counts up to 5

• IS> - increment and skip - Place a variable and a target after this. 1 will be added to the variable and tested to be greater than the number.
IS> is not a looping function, sorry
Format
IS>(variable,#)
command for if false (if variable + 1<#)
command for if true (if variable + 1 > #)

• DS< - decrement and skip - Nearly identical to the IS> function
DS< is not a looping function, sorry
Format
DS<(variable,#)
command for if false (if variable + 1>#)
command for if true (if variable + 1 < #)

• Lbl - any letter or symbol after this will create a marker at this point; use with Goto function below

• Goto - the letter or symbol used for the desired Lbl point will immediately and quickly (great for fast loops) warp to the specified Lbl point

• {1->A
Lbl B
Disp A
A+1->A
Goto B
Bet this'll loop faster than the previous counting program!

• Menu( - Okee...this one's a bit tricky...

Format
Menu("title", "first item", letter(for built in Goto command), "second item", second letter, etc.

Example:

Code
{Menu("TOSS DICE","FAIR DICE",A,"WEIGHTED DICE",B)}

Output
TOSS DICE
1: FAIR DICE
2: WEIGHTED DICE

When an item from the menu is selected, the program runs a Goto function with the assigned letter. So, in this case, if "FAIR DICE" is selected, the program will run {Goto A}. It is crucial that you finish the program with a Lbl A in order for it to perform the correct function.
Also, this particular format may not work on certain calculators like my Ti-85...wish I could help ya guys...

Calling

OK...one last thing..."calling". By putting the name of a another program into your program (actually there's a menu that should display a list of all the other programs to choose from. When the program reads the other program's name, it will execute that program. But there's one catch, you need a special function instead of Stop in your secondary function:

• Return - Put this bad boy at the end of your secondary program or when you want it to return to the main program. This can also be used in a program to bring up the main screen again.
Program A

{Input "A=",A
If A>5
Program B
If A<
Output(4,1,"A is less than 5"}
Program B

{Output(4,1,"A is greater than 5"
Return}

In this example, Program A calls Program B. Of course in this case it is not necessary and this function is not normally used. This function should be used to tie several programs together in a Menu and use the Lbl's to call other programs

Well, that's it! Thank you for flying Kilroy Airlines, your nearest exits are here, and here, and enjoy the rest of your stay here in Everything2.com

Log in or register to write something here or to contact authors.