Beginner TI-85 BASIC
By Anonymous
This article teachers the reader the basics of programming BASIC on the TI-85.

Contents
Introduction
Lesson 1
Lesson 2
Lesson 3
Lesson 4
Lesson 5

Introduction



There is nothing mysterous about a math program. In fact they are often simpler than game programs. Someone asked me what you are suppose to learn in this course. I replied, "What individual commands do." You see, on TI calculators that's all a program is--a group of command lines, and knowing how to put those command lines together to get the results YOU are looking for lets you write programs. Bellow is a simple program. Please type it in by HAND so that you can become as familiar with it as possible. If you've never done this before, you press [PRGM] [F2] for "EDIT" type in the name you want, press [ENTER] and start typing the command lines. Also on the TI-85, you can get xMax, xMin, yMax, yMin, xScl and yScl by pressing [GRAPH] [F2] and then looking for the particular one that you want. You can also get Prompt on the TI-85 or TI-85 by pressing [F3] [F2] as soon as you enter the program name.

Lesson1



The easiest way to learn Basic is by doing it. Let's just get started with your first program. Afterwards, I'll explain to you what you typed.
Name = TRACESCL 

:Prompt X,Y,xScl,yScl
:-6.3X→xMin
:6.3X→xMax
:-3.1Y→yMin
:3.1Y→yMax
:Trace

LINE BY LINE EXPLINAITONS

:Prompt X,Y,xScl,yScl


This command line will "Prompt" X and Y and xScl and yScl. In other words when you run the program by typing the letters of the name, or selecting from the [PRGM] [F1] menu, and press enter you will see X=? on your screen. Enter a number and number will be stored to "X" in the calc's memory. Do the same for "Y=?", "xScl=?" and "yScl=?" Whatever you put for "xScl" will become the distance between the little marks on the x-axis; whatever you put for "yScl" will become the distance between the little marks on the y-axis.

:-6.3X→xMin


Negative six point three will store to xMin in the calc's memory. In other words, whatever -6.3X comes out to be, that will become the fartherst poiont of the negative x-axis displayed on the graph screen. "→" is being used to represent the STORE command on the calc; you can get it by presing the button right above the [ON] key.
:6.3X→xMax


Same for xMax.

:-3.1Y→yMin


Negative three point one stores to yMin.

:3.1Y→yMax


Same for yMax (possative of course). -----Together these command lines give you a graph screen of any size such that when you go to trace you will get whole numbers (like 7) or short decimals (like 5.35) instead of long decimals (like 5.349999999).--------------

:Trace


This command will display the graph screen and start "tracing" along the first selected function. You can get "Trace" from the catalog.

Lesson 2



On the 85 a program is really just a group of commands.
Type this program into your calc with the program name "Agraf"

PROGRAM 2

Name = Agraf 

:Menu(1,"TRCE",B,2,"Promp",C,3,"ZTrig",D,5,"Skip",N) 
:Lbl B 
:Prompt X,Y,xScl,yScl 
:-6.3X→xMin 
:6.3X→xMax 
:-3.1Y→yMin 
:3.1Y→yMax 
:DispG 
:Return 
:Lbl C 
:Prompt xMin,xMax,xScl,yMin,yMax,yScl 
:Return 
:Lbl D 
:ZTrig 
:Lbl N 


EXPLANATIONS
:Menu(1,"TRCE",B,2,"Promp",C,3,"ZTrig",D,5,"Skip",N0) 


A menu command-----menu commands work based on groups of 3 arguments [an argument is any one of the things in the parentacies and between the commas; e.g. the 1, the "TRCE", and the C.] There can be a maximum of 15 arguments, or 5 groups of 3. Here's how it works: the first argument is a number (1-5) for which menu window you want--either the menu window above [ F1 ] or [ F2 ] .... [ F5 ]. You'll see what I mean by "menu window" when you run the program. The second argument is the "string" or group of characters that will appear in the menu window. On the 85 strings are put between "" marks so the calc will know to leave them alone; that is to say so the calculator will "know" that it is just a group of symbols, not something it is supposto understand. The third argument is the name of the label that the the program will goto if the button for that menu group is pressed. OK, this isn't that had; hang with me here--don't get scared and run off. You see, each of the "strings" will appear in one of the five menu windows across bottom of the screen,which window depends on what number is in front of it. Which ever menu button you push [the F1...F5 buttons right beneath the menu], the program will go to the label named by the character/group [of characters [argument] after the that string.

:Lbl B 


Exactly what I was talking about. This command line is read aloud as "Label B"; nevertheless, notice that in the first command line you type :Menu(1,"TRCE",B, ... not :Menu(1,"TRCE",Lbl B. Another point: the "string" that is to appear in the first menu window doesn't have to be the first one in the list of menu arguments--it is only the number in front of the srting that will determine in which menu slot the sgring appears. Moreover, the menu string that you see in the "slot" on the bottom of the screen (you'll see what I mean when you run the program) will ALWAYS shift program control to the menu named by the argument RIGHT AFTER it. YOU CAN GET Lbl AND Menu( ALONG WITH A LOT OF OTHER "CONTROL" COMMANDS BY PRESSING [ F4 ] TO BRING UP THE "CTL" MENU WHILE EDITING THE PROGRAM ON THE 85.

:Prompt X,Y,xScl,yScl 
:-6.3X→xMin 
:6.3X→xMax 
:-3.1Y→yMin 
:3.1Y→yMax 


Creates a trace-freindly graph window.

:DispG 


Displays the graph screen.

:Return 


Stops execution of the program that it is found in, but does not stop all program execution on the TI-85. "Stop" stops ALL of the programs currently being run on the calc. Return is very useful for subroutines [programs called up by other programs] that have menus or other kinds of conditional commands.

:Lbl C 
:Prompt xMin,xMax,xScl,yMin,yMax,yScl 
:Return 


Lbl C is the label that "Promp" leads to and these command lines will "Prompt" xMin...yScl, the varibles that define the appearance of the GRAPH window [in function mode at least]. This lets the person using the program set the graph screen however they want manually. Again, Return is necessary to keep from executing the rest of the program when we only want to set the graph by one method at a time.

:Lbl D 
:ZTrig 
:Lbl N 


Lbl D leads to :ZTrig, a command on the 85 that specially sets the graph for Trigonometric functions [such as sin x, cos x.... if you don't know what they are it doesn't matter for you]. It works in Degree or Radian mode. Lbl N is necessary to give "Skip" in the first command line a place to go to.

Lesson 3

Writing your own math programs doesn't have to be scarry. If you've never typed in your own math programs and understood what they do, these could be your first.

One of the biggest things I don't like about how many people program is that the programs are not as short as they can be. The major problem isn't running the batteries down as many people think, but the shorter a program is the more room it leaves in the memory for other programs. On 85 you have 28 kilobytes of user available memory, but this could still be filled up eventually.

PROGRAMS

The programs Degrees and Radians will be discussed here. As their names suggest, Degrees converts radian angle measurements to degrees, and Radians converts degree angle measurements into radians. You don't have to understand radians and degrees to appreciate the principles that these programs work by. Incidentally, the program's names have to be Radians and Degrees or some other group of characters that suggests the function, but not Radian and Degree since these are the names of mode commands on the 85. Degree [ENTER] on the 85 will put the calc in Degree mode.

Degree - version 1 

:Prompt R 
:R*(180/"pi")-->D 
:Disp D>DMS 


"pi" stands for the pie symbol; you know that funny number about 3.14159...... ">DMS" stands for the Degrees Seconds Minutes command in the catalog that will display a number as so many degrees, so many minutes and so many seconds. Run the program and notice how the resulting number looks.

"→" is the store symbol.

By the way, on the way, on the calc, the ">" in ">DMS" or ">Frac" looks like a small solid triangle; since I don't have such a symbol on my keypad that I know of, I have to approximate it with a greater than symbol: don't use a greater than symbol on your calculator.

This program works and is good, but could be shorter. The "*" symbol for times is unnecessary since R(180/pi) will do the same thing as implied multiplication. It's also not necessary to store the amswer to D since any command line that just does a mathamatical prodedure will store the result to the Ans varialbe; the variable that 10 is stored to when you do 5+5 on the calculator's home screen.

Therefore the program could be:

Degrees - version 2 

:Prompt R 
:R(180/"pi") 
:Disp Ans>DMS 


In fact this version works just as good since anything stored to the answer variable on the last line of a program will automatically be displayed one the home screen.

Degree - version 3 

:Prompt R 
:180R/"pi">DMS 


Radians - version 1 

:Prompt D 
:D*("pi"/180)-->R 
:R/"pi"-->R 
:Disp "Frac of pi =" 
:Disp R>Frac 


Notice anything wrong with this program right of the bat? There are two command lines right next to eachother; this is unnecessary since the last command line could be changed to :Disp "Frac of pi =",R>Frac. ">Frac" is a command in the catalog that will display a decimal as a fraction if it is rational. This program is displaying radains in fractions; pi/3 will come out as 1/3. If you don't understand all of the mathmatical jargon, just know that you can display up to six things at a time with one Disp command by putting commas inbetween them. Only 6 because, more than that may push the first things of the top of the screen before they can be read. Strings like "Frac of pi" that are to be displayed on the screen as you see them have to be inside of parentacies.

Also, if you understand what this program is doing mathmatically, you may notice anther obsolete command line: first you multiply by ("pi"/180) and then divide by "pi". What's the point? Why multiply by pi and them divide by pi? Why not just leave pi out to begin with and get the same answer?

Because of all of the things we've discussed here, this version of Radian works just as well:

Radian - version 2 

:Prompt D 
:Disp "Frac of pi =" 
:D/180>Frac 


By the way, on the way, on the calc, the ">" in ">DMS" or ">Frac" looks like a small solid triangle; since I don't have such a symbol on my keypad that I know of, I have to approximate it with a greater than symbol: don't use a greater than symbol on your calculator.

Lesson 4



INTRO

On the TI-85 when editing a program, you will find that above [ F3 ] is a that window says "I/O"; press it and you bring up the "Input/output" menu. It gives you easy access to commands since if you press the button below the command it will appear at the present cussor location inside the program that is being edited. These commands relate to being able to enter information while running a program is running; they also pertain to telling the program to give you, or output, information.

Input--has two uses. Input A will display a ? in the first column of the row which the cursor is on will store whatever number you give it to A. Input "Starting Number=",N will display Starting Number= and store whatever number you give it to N.

Prompt A,B,C.. Will display A=?, B=?, C=? ... and store whatever you give it to A, B, C... respectively. Prompt can have an infinate number of arguments.

Disp "A=",A,"B=",B,"C=",C will display A=, then what is stored to A, then B=, then whatever is stored to B [and there'd better be something stored to B or you will get an ERROR 14 UNDEFINED], then C= and then whatever is stored to C. Try not to use more than 6 arguments [the thngs between the commas] or some of them will be pushed up above the top of the screen. You see, there are only 8 lines on the TI-85 screen and one blank line tends to get displayed after this, and if the Disp command is at the end of the program, then "Done" will also be displayed on the bottom line of the screen. You can get way with 7 things to be displayed of if there is a pause command right afer the Disp command; if you need to display something on the bottom line of the screen, use an Outpt( command.

DispG displays the GRAPH screen

Outpt(L,C,D) will display whatever is stored to D be it a number, string, list.... starting at whatever line 'L' is and whatever column 'C' is. L must be somewhere between 1-8 and C must be between 1-21.

Outpt(L,C,"D") will display the character D at line L and column C even if there is something stored to D because of the quaotation marks. Watch out because this command doesn't clear any part of the screen before "outputting" the result; it may come out in the middle of something else and get all garbeled up. Therefore the ClLCD command is usually used before this command.

InptS--same as Input, only it automatically stores the results to a string even if what you give it doesn't have parentacies around it.

getKy--returns the code number for a key that is pressed; see user's manuel for more ditails.

ClLCD clears the home screen

PrtScrn-- a command like Pause, only which allows the TI-85 graph link softwhere to be abel to transfer an image of what is currently on the screen while the calc is pausing.

Pause is not on the I/O menu, but is very important anyway. Just :Pause makes the program pause until [ENTER]is pressed; :Pause J pauses while displaying J, and if J is larger than the screen, then you will be able to move it around to see the whole thing. Pause J is usually used for lagre matrices or lists.

" --well what do you think; they're parentacies

Lesson 5



INTRO

[ F4 ] in the program editor (a fancy name for the screen you're in when editing a program) will give you the CTL menu. CTL stands for control.

COMMANDS

IF--what I would call the fundamental conditional statement. It can be used in two ways:

:If condition 
:command line 


will execute that one command line only if the condition is true.

By the way, If x is the same as If x 'does not equal' 0

A CONDITION is something like x==2 or if y>3

:If x<4 
:Then 
:command 
:command 
:command 
:command 
:End 


will execute the unlimited number of commands between the Then and the End only IF x<4

Then--used with If to make more than one command only be executed if a certain condition is true.

Else--used in the middle of an If-Then "loop" to make certian commands only run IF the statement after the If is False.

:If x==2 
:Then 
:command 1 
:Else 
:command 2:command 3:command 4 
:End 


commands 2-4 will execute only if x doesn't equal 2. By the way, it is ok to put multiple commands on the same line and seperate them by a colon.

For( command for going thru a certian number of commands FOR a certain number of times and changing the value of a certain variable from a certain number to another.

:For(A,1,10,2) 
:Disp A 
:End 


will display A five times; the first time a will be 1; the second time A will be 2...the fifth time A will be 10.

You see, the first 'argument', A, is real variable that will travel form the initial vailue (the 1 in this case), to the final value (the 3rd aruement), in increments of the the fourth 'argument'----that's why A kept going up by 2 in our example.

The important thing is order of the arguments; the first argument is always a variable, the second is always the initial value; the third is always the final value. The variable will trabel from the initial value to the final in amounts of the 4th argument. If you leave off the 4th argument, then the calc will assume you mean posative one and take every intager going in the posative direction. If you put a negaitive number, or a variable to which a negative number has been stored, the variable in the first argument--A in our case, will get smaller and smaller and you will need to make sure that the 2nd argument is larger than the 3rd argument.

The For( command will repeat for the number of times it takes the variable to go from the initial value to the final value, which is controled by the increment in the 4th aguement. If you don't want to use the variable in it's increasing or decreasing values, use the command :0-->A [or whatever var you use] to store zero to that variable so that you won't get an error message, and the For( command will repeat for the number of times it would have taken.

End--command to signal the end of a "loop." A loop is a group of commands whose execution is conditional on a For, If-then, While, or Repeat command. There can be multiple loops inside of another loop.

While--command to repeat a group of instuctions WHILE a group of commands is true.

:While X>0 
:A+5-->A 
:B+10-->B          
Imaginary command lines 
:C-5-->C 
:End 


By the way,

:While 1 
:command 
:command 
:command 
:End 


creates an endless loop.

Repeat---repeats a group of comands UNTIL a given comdition is true; the condition isn't tested until the End of the loop, so the loop wil always be tested at least once.

:Repeat C 
:command 
:End 


will repeat 'command' until C doesn't equal zero, since one variable after a conditional statement is the same as that variable doesn't equal to zero. There is a doesn't equal symbol that you will use on your calc. You can get it by pressing [2nd] [2] [MORE] on the TI-85. I just don't have one on my keypad that I know of.

Menu--allows the user to create their own menu's. It was discussed in great detail in Lesson 2.

Lbl string -- marks a certian spot in a program for a Menu or Goto command to transfer control to. string is a group of characters; certian characters are aloud and outhers are not--you play around on the calc and find out about this yourself.

Goto A--will GOTO Lbl A; notice that the command line is Goto A, not Goto Lbl A

IS>(var,#)-- "Increment and Skip"--command that add one to var, and if the result is the result is greater than # it will cause the next command line to be skipped.

DS<(var,#)--"decrement and skip"--command that subtracts one from var and if the result is less than # will cause the next command line to be skipped.

Pause--causes the program to "pause" until [ENTER] is pressed.

Pause var--will display var while Pausing. If var is something big like a matrix or list that goes off the screen, you will be able to move it around using the arrow keys to get a look at the whole thing.

Return--exits the program currently being executed but does not stop all program execution; necessary in some subrutenes (programs used by other programs); see Lesson 2 for an example.

Stop--Stops all program execution and takes you back to the home screen.

& FAIR WELL

Well all good things must come to an end. Personally I have to go back to college now and can't write anymore lessons for this course; nevertheless, feel free to contact me at bevd@bellsouth.net. I share this email address with my mother, so don't be supprised if you see Beverly Deich somewhere. Many of you may be wondering WHAT DO I DO NOW? I'll tell you what to do: keep getting programs from the internet and looking at the command lines to figure out what they do. You may have to get the Free TI-graph link softwhere for your particular calculator from to do this.

Return to index page