TI-Basic 89 Programming/Input

Input

edit

Input, I/O(F3):3 is a command which will display a string and wait for the user to input a value. The value will then be stored into the specified variable once Enter is pressed. The behavior of this command changes depending on how many parameters are passed into it, as explained below.

Syntax: Input

edit
:Input [string],[var]
  • Where string is the optional string to display, and var is the optional variable to store the value to
  • If string is provided, the I/O screen will display that string on a new line, then wait for user input.
  • If string is not provided, the I/O screen will display a ? on a new line, then wait for user input.
  • If neither string nor var is provided, it will display the graph screen and wait for the user to select a coordinate (x value of coordinate is stored into xc, and the y value into yc)
  • Providing only string but not var results in an error ("Argument must be a variable name", errornum 140)


Example: With string

edit
:Input "X Value",x


X Value
5
*The value of 5 would be stored into x

Example: Without string

edit
:Input x


?
5
*The value of 5 would be stored into x

Example: Without arguments

edit
:Input


 
Pressing Enter here would store the coordinates into xc and yc, respectively.


InputStr

edit

InputStr, I/O(F3):4 is much like input, but the values input into this command will always be a string (thus no quotation marks are needed).

Syntax: InputStr

edit
:InputStr [string],var
  • Where string is an optional string to display instead of
  • Where var is the variable the string input will be stored into


Example: InputStr

edit
:InputStr "What is your name",name


What is your name
George
*Pressing Enter would store "George" into the variable name.

Prompt

edit

Prompt, I/O(F3):5 prompts the user to input a number of variables. While this can be used to input more than one variable with one command, it does not give you the flexibility to change what is displayed on screen.

Syntax: Prompt

edit
:Prompt var[,var2][,var3][,…varN]
  • Where var2 through varN are all optional arguments; arguments must be valid variable names.
    • Amount of arguments limited only by available memory
  • For each argument, the prompt will wait until a value is entered and Enter pressed before asking for the next one.


Example: Prompt

edit
:Prompt x,y


x?
5
y?
7
*This would store 5 into x and 7 into y

Request

edit

Request, I/O(F3):1:2 puts a pop-up box on the current screen and allows the user to input a string into it, and then stores that string into a variable. Request can be used as a stand-alone command or as part of a Dialog block (more on those later).

Syntax: Request

edit
:Request string,var
  • Where string is the string to be displayed before the input box
  • Where var is the variable the string gets stored into
  • Request automatically turns a-lock on, so the alpha button must be pressed once before numbers and other symbols may be entered


Example: Request

edit
:Request "name",x


 
The string put into the input box will be stored into the variable x.


edit

PopUp, I/O(F3):1:3 displays a pop up window with a number of choices for the user to choose between (passed in as a list). Then, the number of the choice the user selects will be stored into the variable given.

Syntax: PopUp

edit
:PopUp itemlist,var
  • Where itemlist is a list of strings that will appear in the popup.
  • Where var is the variable that the number of the choice will be stored to.


Example: Correct equation

edit
:PopUp {"1+2=2","1/2=2","1-2=2","1*2=2"},x


 
When Enter is pressed, the value 4 will be stored into x.


Passing in Arguments

edit

Passing in arguments is vital to functions, and can be helpful in programs as well. In order to get an argument to be passed in, it must be declared in the opening parenthesis of the program editor. Then, when calling the program (by typing prgmname() in the home screen), you put the declared arguments into the parenthesis, like so: prgmname(arg). Note: for all of the following examples, the name of the function is "temp" (and it is a function).

Syntax

edit
temp([var1][,var2][,var3][,…varN])
  • Where var1 through varN are all valid variable names
    • The amount of variables passed into the function is limited only by the amount of available memory
  • The variables passed in are local variables, as in they disappear the moment program execution stops (unlike from the previous ways of input, where the variables stick around until they are deleted).


Example: Temp

edit
temp(x,y,z)
Func
Return x^2+(y*z)/100
EndFunc


Let's say you call this program like so: temp(12,4,52). The following will appear on your home screen:

▪temp(12,4,52)      146.08



Previous: Output
Next: Conditional Functions
Table of Contents: TI-Basic 89 Programming