Introduction
TI-BASIC is the built-in program language that comes with the TI-83/84+ calculators
Optional Resources
1. TI-83 Plus Flash Debugger -> for running programs
2. TI Graph link -> For writing & saving programs
-or-
a TI-83/84 Plus calculator -> writes and runs programs
Input Methods
The TI BASIC programming languages have several methods of getting input from a user. The most common ways include the following:
Note: GetKey is not in this tutorial (will be in a future tutorial)Code::Menu( :Input :Prompt :GetKey
:Menu(
InputSyntax
The syntax above has a function in TI-BASIC that I have not yet mentioned.Code:Menu("Title", "Option 1", Lbl1[, "Option 2", Lbl2...]
Lbl1 is a label. Labels are basically checkpoints in the code with a name. When the code is told to go to the label, the processor starts from the top of the file checking each line for the correct label, and when it finds it, it starts from there.
To set a label use the function Lbl XX
For example:
Labels can be anything as long as they are only 2 characters. (Use Goto to refer immediately go to a label) The previous code creates an infinite loop, and can also be written as:Code::Lbl BB :Goto 5 :Blahllalhlalhlahllhl skipped code blallalhlahll :sdgldlgslkdgsldk -> anything in here triggers no syntax error or any type of error at all because it is skipped by the Goto command :Lbl 5 :Goto BB
Now back to the Menu( command. If for example, you would like to create a menu that would let the user choose a certain type of food and then do something with that based on what they choose, Menu( is very easily implemented:Code::Lbl BB :Goto BB
When run, this code will give a menu with 4 options, each displaying something different when you select it, pausing, and then returning to the menu.Code::Lbl MM :Menu("Choose Food", "Bagel", BG, "Banana", BN, "Grilled Chicken", GC, "Exit", XX :Lbl BG :Disp "You ate a bagel" :Pause :Goto MM :Lbl BN :Output(1,1, "You eat banana!" :Pause :Goto MM :Lbl GC :Text(0,0, "Eat Mor Chikin" :Pause :Goto MM :Lbl XX :ClrDraw :ClrHome :StopPromptInput receives expr input from a user (expr means it can be a variable or matrix or whatever as long as it matches the input type)
Syntax for Input is as follows:
Var is the variable to which the input is stored, and "Prompt" is the message displayed to the user before they give input. If neither Var nor "Prompt" is included in the code, a crosshair will be created on the graphscreen and the calculator will get input from the coordinates.Code::Input [Var, ["Prompt"]]
Examples:
This code will give the prompt "Enter your age: " and then will display it on the graphscreen.Code::Input A,"Enter your age: " :Text(57,0,"You are ", A, " years old."
Note that Input uses the homescreen.
Now you know how to get input from a user.Prompt is similar to Input. The only difference is that you dont need to give a prompt.
For example:
This will display on the homescreen the following:Code::Prompt X, Y :Disp "Hypotenuse length is ", (x^2+y^2)^(1/2)
<enters a number, say for example 4>Code:X=?
<enters another number, 3>Code:X=?4 Y=?
Code:X=?4 Y=?3 Hypotenuse length is 5
CHALLENGE:
Make a program where the user tries to guess a secret number you have chosen. Hint: use Input
Post your code here.
Last edited by exfyre; 08-28-2009 at 06:52 PM.
Well done. +rep
Very cool! +rep
It would be fun to make a basic text-based RPG game on the TI. I like how you include a challenge at the end.![]()
Thanks. I've actually made a Text based rpg that is somewhat entertaining - and a bit buggy. I'll post it when I get a chance to download it from my calculator. It's a bit old and uses some inefficient programming techniques, but it's pretty nice.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks