TI-Basic Z80 Programming/Input
Input functions accept data from the calculator's user. Input and output functions can be found underI/O.
Input ( I/O 1) accepts both keyboard and graph point data.
Input [variable] Input ["text",variable] Input [Strn,variable] no arguments
- If no variable is passed, Input will open the graph and the user will select a point by using the arrow keys and .
- If a variable is passed, Input will store the user's input into this variable.
- If a string or text is provided with the variable, the text will be displayed and the user input will follow on the same line.
Input without a variable will open the current graph and pause the program. The arrow keys can be used to move the cursor. Whenis pressed, the variables X and Y will be updated with the X,Y position of the cursor. In PolarGC mode, R and θ will be updated instead.
If a variable follows Input, the program will accept a value from the keyboard and store it in the variable whenis pressed.
If the format
Input "string",variable is used, the calculator will display up to 16 user-defined characters before accepting input. If Strn is used, Strn is string number n, accessed with 7 n. Note that "text" must be contained in quotation marks ( ["]).
This code returns the X,Y coordinates of the graph cursor:
This code accepts a value from the keyboard, stores it in the variable called A, and displays it:
This code displays what the program is looking for, accepts and stores a numeric value from the keyboard in the variable called A. Then A is displayed:
Prompt ( I/O 2) gets user input for one or more variables at a time. It displays the variable name followed by
=? for each variable, waiting for keypad input followed by before continuing. Each value entered is stored in its respective variable.
Prompt variableA[,variableB,...,variable n]
Prompt is useful for quick user input, but should be avoided due to the limitation that only the variable name can be displayed.
Displays the following:
A?=5 Value is 5
Displays the following (with user input):
M?=5 G?=9.81 H?=2 PE = 98.1
You try it!Edit
Try these examples to practice getting and handling user input.
The Pythagorean Theorem states that, for any right triangle with legs A and B and hypotenuse C, . Write a simple program that can calculate the hypotenuse C given values A and B, and display it to the screen. You can use the Input or Prompt commands.
Because , .
* Note: It is also acceptable to use two Prompt commands: one for each variable. But, by combining them into one command, several bytes are saved.
* Note: The text argument of the input commands is arbitrary as it does not the affect the value of the user input.
Write a program that asks the user what their name is, and respond, using their name.
This would appear as (with user input):
TYPE YOUR NAME NAME: JACOB HI, JACOB I'M YOUR TI-84!
Write a program the allows the user to enter their age in years, then display their age in hours, then in minutes, then in seconds.