TI-BASIC/Input

From Wikiversity
Jump to navigation Jump to search

The few previous functions may help write some excellent programs, but what does the user do while the program is running? They act more as movies than programs, so to have interactive features on a program, it needs to listen to the user.

PROGRAM:NAME
:While 1
:Output(1,1,getkey
:End

getkey is in I/O in the program menu. Getkey is a very valuable function, because once a button is pushed in program, it returns a value. This feature may be used alongside conditions, and create an interactive program.

the values associated to the buttons with the getkey function
PROGRAM:NAME
:ClrHome
:1→A
:1→B
:Output(A,B,"O"
:While 1
:getkey→K
:If K=/0
:Output(A,B," "
:X-(K=24)+(K=26)→X
:Y-(K=34)+(K=25)→Y
:If K=/0
:Output(A,B,"O"
:End
:End

This may seem very large, but in each line are very simple instructions, together it tells the program what is allowable. When followed correctly, this program is an O that moves around the screen according to the arrow keys.

prompt[edit | edit source]

Prompt is a function that allows the user to give a value to a variable (between A to θ).

PROGRAM:NAME
:Prompt A
:Disp A

Input is similar to prompt, but what is displayed can be altered.

PROGRAM:NAME
:Randint(1,500→A
:While 1
:Input B,"GUESS:"
:If A=/B
:Disp "NOPE"
:If A=B
:Disp "YOU GOT IT"
:End

Randint( can be found in math. This program is the standard guess the number game, you can play with and show your friends on a slow day.
back next