Donate to support Ukraine's independence.

TI-83/TI-84 BASIC Tutorial #4

User Input

In your program, you will most likely want to have some form of input from the user. You can ask for a number, function, or string.

First off, we'll do a number.
:Input A
:Disp A

And the user would see (assuming they enter 4):
?4
               4
Now the four is stored into A for later use. But say you don't want that question mark as the prompt. Say you want "PLAYERS: " as the prompt. Well, You can do that..
:Input "PLAYERS:
 ",A
That is a little more informative and lets the user know what they are entering. They would see
PLAYERS: 4

It's more user-friendly, and that's what counts. Now, say you don't want a number from the user. Perhaps you want a string of letters. You can't use a real variable for this. You need to make use of the string variabled which can be accessed by pressing [VARS][7] and [1],[2],..., [9],[0] depending upon the string you want. So here's a real world example:

:Input "Name: ",
Str1
:Disp "Hello,"
:Disp Str1
They see a nice prompt for their name:
Name: Bart
Hello,
Bart
Programmer's Tip
Did you know you can put a string from your program and a string in a variable on the same line using a single Disp command by using a plus sign. Example: Disp "HI, "+Str1.

Previous tutorial ^ Next tutorial



This is how we (partially) recoup costs

Valid XHTML 1.1