TI-BASIC:Input

From Learn @ Cemetech
Jump to navigationJump to search

INPUT ANIMATED.gif

Command Summary

Prompts the user to enter a value and then stores the value to the variable.

Displays the graph screen and then the user can move around the cursor.

Command Syntax

Input

Input ["Text",]variable

Menu Location

While editing a program press:

  1. PRGM to enter the PRGM menu
  2. RIGHT to enter the I/O menu
  3. 1 to choose Input

Calculator Compatibility

TI-83/84/+/SE

Token Size

1 byte

The Input command is the other way of getting user input on the home screen (getting user input on the graph screen is only possible with the GetKey command). The Input command asks the user to enter a value for a variable (only one variable can be inputted at a time), waiting until the user enters a value and then presses ENTER. It does not display what variable the user is being asked for, but instead just displays a question mark (?).

Because just displaying a question mark on the screen does not really tell the user what to enter for input or what the input will be used for, the Input command has an optional text message that can be either text or a string variable that will be displayed alongside the input.

Only the first sixteen characters of the text message will be shown on the screen (because of the screen dimensions), so the text message should be kept as short as possible (a good goal is twelve characters or less). This is so the value the user inputs can fit on the same line as the text. In the case that the value is too long, it will wrap around to the next line.

PROGRAM:INPUT
:"Fruit
:Input "Best "+Ans,Str1
:Input "Worst "+Ans,Str2
:Disp "That's "+Ans+"astic!

Input can be used to display every variable just before it requests user input, but some of the variables have to be entered in a certain way. If the variable is a string or a Y= function, the user must put quotes ("") around the value or expression. The user must also put curly braces ({}) around lists with the list elements separated by commas, and square brackets ([]) around matrices with the matrix elements separated by commas and each row individually wrapped with square brackets.

Advanced Uses

When you just use the Input command by itself (without any arguments), the graph screen will be shown and the user can move the cursor around. Program execution will then Pause until the user presses ENTER, at which time the coordinates of the cursor will be stored to the respective variables (R and θ for PolarGC format, otherwise X and Y).

If a text message is longer than twelve characters or you want to give the user plenty of space to enter a value, you can put a Disp command before the Input command. You break the text message up and display it in parts. The Input command will be displayed one line lower, though, because the Disp command automatically creates a new line.


:Disp "What is your"
:Input "Name",Str0


Normally you can't get a quote character into a string (because quotes are used to identify the beginning and end of the string), but the Input command actually allows the user to enter a quote character (") as part of a string. This works without problems, and the quote can even be accessed by the user afterwards.

Because a user-defined list variable doesn't need the ,,L,, prefixed character before it when referring to the list, you may be only asking the user to input a simple real variable but a list would also be allowed. There is nothing you can really do about this problem, except including the ,,L,, prefixed character when wanting a list inputted and trying to limit your use of Input and Prompt.


:Input A
should be
:Input LA


Optimizations

When you are just using the text message to tell the user what the variable being stored to is, you should use the Prompt command instead. And, if there is a list of Input commands following the same pattern, you can reduce them to just one Prompt command.


:Input "A",A
:Input "B",B
Replace with Prompt
:Prompt A,B


Error Conditions

  • ERR:INVALID occurs if this statement is used outside a program.

Related Commands