TI-Basic 89 Programming/Input
Input
[edit | edit source]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 | edit source]: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 | edit source]
X Value 5
Example: Without string
[edit | edit source]
? 5
Example: Without arguments
[edit | edit source]
InputStr
[edit | edit source]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 | edit source]: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 | edit source]
What is your name George
Prompt
[edit | edit source]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 | edit source]: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 | edit source]
x? 5 y? 7
Request
[edit | edit source]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 | edit source]: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 | edit source]
PopUp
[edit | edit source]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 | edit source]: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 | edit source]
Passing in Arguments
[edit | edit source]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 | edit source]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 | edit source]- 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