Está en la página 1de 10

26/9/23, 06:25 TI-Freakware | Tutorials | BASIC | TI-82 | Calc.

org Content | Beginner TI-82 BASIC

Hogar Archivo Foro Tutoriales Enlaces IRC Concurso Proyectos Panel de control

Comenzando con TI-82 BASIC


Por Anónimo
Este tutorial enseña al lector los conceptos básicos de la programación TI-82 BASIC.

Tabla de contenido
Lección 1: Primeros pasos
Lección 2: Visualización de texto
Lección 3: Variables e ingreso
Lección 4: Declaraciones If...Then...Else
Lección 5: Bucles
Lección 6: Números aleatorios y tu primer juego
Lección 7: La pantalla gráfica

Lección 1: Primeros pasos


Para escribir un programa BÁSICO en la TI-82, primero debe acceder al editor de programas. Para llegar allí, presione PRGM. Luego vaya al
menú NUEVO y presione Entrar. La calculadora dice "Nombre=" seguido de un cursor parpadeante. Aquí es donde escribes el nombre del
programa que escribirás. Simplemente escriba lo que quiera aquí por ahora y presione Entrar. La pantalla que aparece es el editor de programas,
donde puedes ingresar los comandos que componen tu programa. Los comandos se encuentran en menús a los que puede acceder presionando el
botón PRGM. El menú CTL (que significa Control) contiene comandos que le indican a la calculadora que realice tareas "entre bastidores", como
tomar decisiones o saltar a otras partes de un programa. El menú E/S (que significa Entrada/Salida) contiene comandos que le indican a la
calculadora que haga cosas que el usuario verá suceder, como mostrar texto o permitirle ingresar números. Simplemente ignore el menú EXEC
por ahora. Para salir de los menús, presione CLEAR.

Para salir del editor de programas, presione 2nd QUIT para volver a la pantalla de inicio. Para editar un programa que ya inició, presione PRGM,
vaya al menú EDITAR y elija su programa. Cuando finalmente esté listo para ejecutar su programa, presione PRGM, luego seleccione el nombre
del programa en el menú EXEC. Si alguna vez necesita eliminar un programa, presione 2nd MEM, elija Eliminar..., elija Prgm..., seleccione el

tifreakware.net/tutorials/82/b/calc/begin82.htm 1/10
26/9/23, 06:25 TI-Freakware | Tutorials | BASIC | TI-82 | Calc.org Content | Beginner TI-82 BASIC

programa que desea eliminar y presione Intro. (Nota: ¡Ten mucho cuidado con este! Una vez que presiones Enter la última vez, ¡el programa
desaparecerá PARA SIEMPRE!) Usa 2nd QUIT para volver a la pantalla de inicio cuando hayas terminado de borrar cosas.

Bien, entonces todo lo que necesitas saber cómo hacer ahora es escribir el programa. Empezaremos con algo sencillo.

Lección 2: Mostrar texto


Mostrar texto en la pantalla es probablemente lo más sencillo que se puede hacer en la calculadora, pero también es uno de los más importantes. Si
un programa no muestra nada en la pantalla, ¡el usuario no sabrá lo que está pasando!

El comando Disp se utiliza para mostrar texto. Para acceder, presione PRGM, vaya al menú E/S y elija la opción 3. (De ahora en adelante, usaré
abreviaturas como PRGM:I/O:3 para indicar qué opción de menú elegir. PRGM: I/O:3 lo llevará al comando Disp). Para ver cómo funciona este
comando, cree un nuevo programa e ingrese lo siguiente (presione ENTER al final de cada línea):

:Disp "ESTO ES TEXTO" (Obtienes citas presionando ALFA, luego +)

:Mostrar "12345"

:Dispensador 12345

:Mostrar "3+3"

:Display 3+3

Ahora salga del editor de programas y ejecute el programa que creó. Deberías ver algo parecido a esto:

Las dos primeras líneas fueron bastante predecibles; simplemente imprimieron lo que había dentro de las comillas. Pero observe lo que pasó con
el 12345 cuando eliminamos las comillas. El número alineado en el lado derecho de la pantalla. Siempre que utiliza el comando Disp sin comillas,
el número se alinea a la derecha en lugar de a la izquierda. (Tenga en cuenta que no puede usar letras sin comillas. Si lo hace, obtendrá cosas raras
en lugar de letras. Aprenderemos sobre eso en una lección posterior). La cuarta línea funcionó igual que las dos primeras en el sentido de que
Acabo de imprimir lo que había dentro de las comillas. Cuando quitas las comillas, como en la quinta línea, la calculadora calcula qué es 3+3 y
muestra la respuesta. Esto es útil para programas que realizan cálculos para el usuario.

Una nota más sobre cómo mostrar cosas en la pantalla. Tenga en cuenta que cuando ejecutó su programa, aún podía ver las cosas que había escrito
antes de ejecutar el programa. Generalmente es una buena práctica iniciar su programa con un comando ClrHome (PRGM:I/O:8), que borra la
tifreakware.net/tutorials/82/b/calc/begin82.htm 2/10
26/9/23, 06:25 TI-Freakware | Tutorials | BASIC | TI-82 | Calc.org Content | Beginner TI-82 BASIC

pantalla de inicio. Para hacer esto, regrese a su programa (usando el menú PRGM:EDITAR). Vaya al principio de la primera línea del programa y
presione 2nd INS. Ahora presione ENTER para crear una nueva línea antes de la primera. Vaya a la nueva línea e ingrese un comando ClrHome.
Cuando ejecuta el programa, observe que la salida (lo que escupe el programa) comienza en la primera línea de la pantalla.

Lección 3: Variables y entradas


Ahora ya sabes cómo mostrar cosas en la pantalla, pero para ser honesto, eso por sí solo se vuelve bastante aburrido después de un tiempo. Para
que un programa sea interesante, o al menos útil, el usuario tiene que poder interactuar con él. Pero antes de poder hacer eso, debes entender qué
son las variables.

Inicie un nuevo programa e ingrese los siguientes comandos:

:ClrInicio
:3->A ​
(Para obtener el símbolo ->, presione la tecla STO>, justo encima del botón ON)
:Display A
:3+5->A
:Display A
:A*2->A
:Display A

Cuando ejecutas el programa, deberías ver esto:

O.K., this is what happened here. The first statement clears the home screen. Then comes the statement 3->A. This takes the value 3, and says
whenever the program sees the letter A (outside of quotation marks), it means 3. So when the program says Disp A in the third line, it knows to
display 3. The next line says to take 3+5, calculate it, and store the result as A. This means that A does not mean 3 anymore; it means 3+5, or 8,
which is displayed in the next line. The next line is a little strange - A*2->A. What the program sees this, it takes the current value of A, 8, and
multiplies it by 2, making 16. Then it stores that answer as A, making A equal to 16. You can use any combination of expressions and other
variables when defining a variable. The only thing you can't do is make a variable equal a word or group of letters (called a string). In other words,
the statement "VARIABLE"->A will give you an error. And by the way, a variable does not always have to be called A. It can be any letter A-Z, or
theta, so you can have up to 27 different variables at once.

So now that you know what variables are, what can you do with them? They're not very useful if you have to define them within the program
itself. The main use for variables is letting the user define the variable, and then doing stuff with what the user defines. You can do this with the
Input (PRGM:I/O:1) statement. Enter the following program:

:ClrHome
:Input N

tifreakware.net/tutorials/82/b/calc/begin82.htm 3/10
26/9/23, 06:25 TI-Freakware | Tutorials | BASIC | TI-82 | Calc.org Content | Beginner TI-82 BASIC

:Disp "YOU ENTERED:" (To make a colon, press 2nd decimal point)
:Disp N

When you run it, you will see a question mark and a flashing cursor. This means that the calculator is waiting for a response from the user. Enter
any number and press enter. The program then stores the number as N, and displays whatever you entered. For example:

The only problem with this is that if the person using your program doesn't know what your program does, he or she won't know what to do when
the cursor pops up. To fix this, enter teh following:

:ClrHome
:Input "ENTER NUMBER: ",N
:Disp "YOU ENTERED:"
:Disp N

Now, instead of a question mark and a cursor, the program will say ENTER NUMBER: followed by a cursor. Let's do one more example of this to
show more about how variables and Input work together. Enter the following program:

:ClrHome
:Input "NUMBER 1:",A
:Input "NUMBER 2:",B
:(A+B)/2->C
:Disp "THE AVERAGE IS:"
:Disp C

This program lets the user enter two numbers, finds the average of them, and displays it. This shows why you might want more than one variable
in a program. These past two lessons have dealt with the two major concepts of a program: letting the user input information, and giving the user
information. Now, it's time to do some interesting things with the information.

Lesson 4: If...Then...Else statements


At some time or another, most programs have to make a decision of some sort, doing one action under a certain condition, or another action under
a different condition. The way you can accomplish this is with an If (PRGM:CTL:1) statement. Try this program:

:ClrHome
:Input "ENTER AGE: ",A
:If A>17 (The > sign is at 2nd TEST:TEST:3, along with the other conditional symbols)

tifreakware.net/tutorials/82/b/calc/begin82.htm 4/10
26/9/23, 06:25 TI-Freakware | Tutorials | BASIC | TI-82 | Calc.org Content | Beginner TI-82 BASIC

:Disp "YOU CAN VOTE"


:Disp "THAT'S COOL" (The apostrophe is under 2nd ANGLE:ANGLE:2)

O.K., so it's a dumb program that doesn't do much. The point is to notice what happens when you put in an age bigger than 17, and what happens
if you put in a smaller one. Here is what you should get when you run the program using different values for A:

See what the If statement on the third line does? If the condition A>17 is true, then the line after the If statement executes; otherwise the program
ignores it. What if you want more than one thing to happen if the condition is true, though? In this case, you would use a Then (PRGM:CTL:2)
statement. Put the commands you want to occur between Then and End (PRGM:CTL:7), and those statements will only happen if the If statement
is true. Look at this example:

:ClrHome
:Input "ENTER AGE: ",A
:If A>17
:Then
:Disp "YOU CAN VOTE"
:Disp "OR JOIN THE ARMY"
:End
:Disp "THAT'S COOL"

Now the program will display YOU CAN VOTE and OR JOIN THE ARMY if the age is 18 or over. Now, what if you wanted to display
something is the person is 18 or over, and display something different if they're younger than 18? You do this with an Else (PRGM:CTL:3)
statement, which is used like this:

:ClrHome
:Input "ENTER AGE: ",A
:If A>17
:Then
:Disp "YOU CAN VOTE"
:Else
:Disp "YOU CAN'T VOTE"
:End

If A is bigger than 17, the program displays YOU CAN VOTE; otherwise it says YOU CAN'T VOTE. Notice that you still have to use Then and
End if you use Else, even if you only want to have one command occur.

tifreakware.net/tutorials/82/b/calc/begin82.htm 5/10
26/9/23, 06:25 TI-Freakware | Tutorials | BASIC | TI-82 | Calc.org Content | Beginner TI-82 BASIC

The last thing to know about If statements is all the comparisons you can make. Below are some charts that list all the different comparisons you
can make. Notice that you can make more than one comparison in a single If statement. For example, if you wanted to test to see if someone's age
was between 18 and 21, you would say If A>17 and A<21... to do it. The words you use to joins comparisons are under 2nd TEST:LOGIC.

Operator Comparison 1 Comparison 2 Result


True True True
Symbol Meaning
and True False False
= is equal to
False False False
≠ is not equal to
True True True
> is greater than
or True False True
≥ is greater than or equal to
False False False
< is less than
True True False
≤ is less than or equal to
xor True Flase True
False False False

Lesson 5: Loops
Loops are very useful statements that let you repeat a set of commands over and over without having to type them many times. For instance, say
you wanted to make a program that displayed the numbers 1-100. You could do it like this:

:ClrHome
:Disp 1
:Disp 2
:Disp 3

and so on, but that would take a LONG time to enter. To avoid this, you can use what is called a For (PRGM:CTL:4) loop. For loops let you repeat
any number of statements a specified number of times. Here's what our counting program would look like with a For loop:

:ClrHome
:For(F,1,100,1)
:Disp F
:End

tifreakware.net/tutorials/82/b/calc/begin82.htm 6/10
26/9/23, 06:25 TI-Freakware | Tutorials | BASIC | TI-82 | Calc.org Content | Beginner TI-82 BASIC

The second line looks pretty strange, doesn't it? Here's what it does. First, it takes a variable (F in this case), and makes it equal to 1, which is the
second thing in the parentheses. Then the program continues until it hits an End statement. At this point, the program adds one to F (kind of like
saying F+1->F). If F is smaller than the third number (100), the program loops back to the For statement and performs the commands inside the
loop again. Otherwise, the loop ends. As another example, let's say you wanted to display all the even number from 1-100. Here's what you do:

:ClrHome
:For(F,2,100,2)
:Disp F
:End

Observe lo que cambió en la segunda línea. El primer número cambió de 1 a 2 porque queremos mostrar números pares y 1 es impar. Además, el
último número cambió de 1 a 2. Esto significa que en lugar de sumar 1 a F cada vez que finaliza el ciclo, el programa suma 2.

Bueno, esto está bien si sabes cuántas veces quieres que se realice el ciclo, pero ¿qué pasa si no sabes cuántas veces repetir el ciclo? Por ejemplo,
¿cómo crearías un programa que le pida a un número que ingrese un número una y otra vez hasta que ingrese un 0? Puede hacer esto con un bucle
While (PRGM:CTL:5). Mira este ejemplo:

:ClrInicio
:Ingrese "TIPO 20: ",N
:Mientras N<>20 (En lugar de ingresar <>, ingrese el signo igual con una línea atravesado)
:Disp "¡ESO NO SON 20!" (El signo de exclamación está en MATH:PRB:4)
:Ingrese "TIPO 20: ",N
:Fin

When the program starts, the user is asked to enter 20, and the program stores whtever the user entered as N. Then, if the user did not enter 20, the
commands inside the While loop happen. The While loop repeats as long as the condition in the While statement is true. Once N=20, making the
While loop FALSE, the While loop ends.

One thing to be careful about with While loops is what is called an infinite loop. Check this out:

:ClrHome
:10->N
:While N>0
:Disp N
:N+1->N
:End

This loop will never end!! N starts as being 10, and every time the loop occurs, N gets bigger. N will always be greater than 0, so the loop will go
on forever. To stop the program when something like this happens, press the ON button. This kind of error is actually pretty common, so do your
tifreakware.net/tutorials/82/b/calc/begin82.htm 7/10
26/9/23, 06:25 TI-Freakware | Tutorials | BASIC | TI-82 | Calc.org Content | Beginner TI-82 BASIC

best to avoid it.

Lesson 6: Random numbers and your first game


Up until this point, the program examples have been pretty simple, and pretty useless as well (except for teaching). Now we're going to put all
these things together to make a game. The game I had in mind was a random number guessing game, where the calculator will "think" of a
number between 1 and 100, and the user will try to guess. The only thing left to learn before we make this game is how to tell the calculator to
make a random number. Here is the command to do it:

:int ((high + 1 - low)rand+low)->variable

int is located at MATH:NUM:4 and rand is at MATH:PRB:1. Do not actually type in what is in italics. High means the highest number the random
number can be (in our game it will be 100). Low is lowest number (1 in our game). Variable is whatever variable you want to represent the
number. So to make a random number between 1 and 100, you would enter:

:int (100rand+1)->N

O.K., so let's get to the game. Try to follow in your head what the program does, line by line, before you read the paragraph after the listing. This
will help you to understand how the calculator interprets programs.

:ClrHome
:int (100rand+1)->N
:0->G
:While G<>N (use the equals sign with a slash instead of <>)
:Input "ENTER GUESS:",G
:If G>N
:Disp "TOO HIGH"
:If G

The first line clears the screen. Then, the calculator makes a random number between 1 and 100 and stores it as N. Then it stores 0 as G (this is so
G and N are sure to be unequal before the While loop starts). The calculator tells the user to enter a guess, and it stores the guess as G. If the user
guesses too high (G>N), the program says "TOO HIGH!" If the user guesses too low (G

Congratulations! You've just made your first game using all the commands covered in the previous lessons. Now you know all the basic
commands necessary to make any text-based game. But while many (probably most) of your programs will be text-based, what if you wanted
graphics in your programs? Well, that's where we go from here...

tifreakware.net/tutorials/82/b/calc/begin82.htm 8/10
26/9/23, 06:25 TI-Freakware | Tutorials | BASIC | TI-82 | Calc.org Content | Beginner TI-82 BASIC

Lesson 7: the Graph Screen


While text games are okay, graphics make everything better. Unfortunately, you can't make graphics on the home screen (at least, not very well).
To do good graphics, you need to use the graph screen. The graph screen is where you see all of your functions graph (obviously). The graph
screen is 94 pixels across by 62 pixels down. To display things on the graph screen, you have to tell the calculator what coordinate you want it
display on. Here's a list and a brief description of what most of the commands for the graph screen do:

Command Description Location


ClrDraw The equivalent of ClrHome for the graphscreen. It clears the graphscreen 2nd, PRGM, 1
Line( Draws a line between the point X1,Y1 and X2,Y2 2nd, PRGM, 2
Horizontal Draws a horizontal line at the Y-coordinate specified 2nd, PRGM, 3
Vertical Draws a vertical line at the X-coordinate specified 2nd, PRGM, 4
Text( Displays starting Y pixels down, X pixels to the right 2nd, PRGM, 0
Pxl-On/Off/Change Turns on, off, or toogles the pixel that is y pixels down and X pixels to the right 2nd, PRGM, >, 4/5/6
Pxl-Test( Represents a number value of 1 if the specified pixel is on, 0 if it's off 2nd, PRGM, >, 7

As a general rule, I start each program where I'm going use the graph screen like this:

:ClrDraw
:FnOff (2nd Y-VARS:5:2 - this keeps any functions in the Y= screen from graphing)
:AxesOff (WINDOW:FORMAT:AxesOff - this keeps the x- and y-axes from showing up)
:0->Xmax (VARS:1:X/Y:1)
:94->Xmin (VARS:1:X/Y:2)
:-62->Ymin (VARS:1:X/Y:3)
:0->Ymax (VARS:1:X/Y:4)

Those last four lines make it so that if you use Line, Horizontal, or anything that use points on the coordinate plane, the numbers will be the same
as if it used pixels down and to the right. The only difference is that you use a negative number for pixels down. Now, these settings could make
people mad at their calculator after the game is over, because it messes with their viewing window for graphs. To fix this, I use these lines at the
end:

:ZStandard (ZOOM:ZOOM:6)
:AxesOn (WINDOW:FORMAT:AxesOn)
:FnOn (2nd Y-VARS:5:2)

tifreakware.net/tutorials/82/b/calc/begin82.htm 9/10
26/9/23, 06:25 TI-Freakware | Tutorials | BASIC | TI-82 | Calc.org Content | Beginner TI-82 BASIC

And that's about it! Now you can program just about anything at all on the calculator! Soon I'll make an advanced TI-82 programming lesson
which will tell how to do animation, use lists and matrices, and other cool stuff that can help your programs be even better. But for now, just try
stuff out; that's the best way to learn BASIC. Experiment with commands; you can't do anything that will hurt your calculator. And last (but
definitely not least!), tell me what you thought of the lesson! If you have any questions or comments, or need help with program, PLEASE feel
free to e-mail me at carb0001@unf.edu. I'll be glad to answer any question. Have fun programming!

tifreakware.net/tutorials/82/b/calc/begin82.htm 10/10

También podría gustarte