TI99 Environment

TI_INPUT


Syntax

string-variable=TI_INPUT(prompt-string)

Description

This function pauses program execution to accept user input. Input always starts at row 24. Any input text that overflows to the right edge of the screen causes the input line and everything above it to scroll up and input to continue at the first tab column of row 24.

prompt-string can be used to include an informational message with instructions prompting users to enter specific data. The return value string-variable contains the user input after the user hits the -Enter- key. Leading spaces in user input are ignored, for example, pressing space bar first without having any input text is ignored.

TI_Input always returns a string value. To convert the text into a numeric value, use the VAL function: number=VAL(TI_Input("..."))

If prompt-string is null (""), the function will work as TI-BASIC's - INPUT "" :string-variable, it will NOT display the ? character at the prompt. User input starts at tab 1 (col 3).

If prompt-string is NOT null, the ? prompt character will not be displayed, and input starts immediately following the prompt text; the function will work as TI-BASIC's - INPUT prompt-string : string-variable. To add ? to the prompt use TI_Input("?"). Example: INPUT A$ will be entered as A$ = TI_INPUT("?"). The ? prompt or text prompt starts at column 3 (or TI_Print tab 1). User input starts two spaces after the ? prompt, column 5 (tab 3) when prompt is "?".

User Input: The function accepts alphanumeric characters, space and backspace. To include leading spaces in the input text, user must enclose text between quotes. Example: " my text with 5 leading spaces". A maximum of four lines of input are allowed, including the line with the prompt-string characters. As in TI BASIC, the maximum input-string length is 112 characters (4 lines x 28 characters per line), assuming a null prompt. This length is reduced by the number of characters in the prompt text.

  Example Code
` Program that displays a sprite with a butterfly shape and moves it in random directions and speeds based on user input 
randomize hitimer()
call_char(128,"249999FF3C7E4281")
call_char(129,"665A5A7E3C7E4242")
call_char(130,"A599DB7E3C7E4224")
call_createanimation(1,128,3,1)
call_sprite(1,128,5,96,128,0,0)
call_createanimatedsprite(1,1,100)
call_pauseanimatedsprite(1)
ttn = 250
do
 gosub _inputlvl 
 tiwait(100)
 gosub _movebutterfly 
loop
_inputlvl:
  repeat     
	 lvl = VAL(TI_INPUT("Speed:"))
  until lvl > 0 and lvl <= 128
  call_resumeanimatedsprite(1)
 call_clear()
 a$ = ""
 tt = timer()
return
_movebutterfly:
 do
  if timer() > tt + ttn
   call_motion(1,rnd(lvl)-rnd(lvl),rnd(lvl)-rnd(lvl))
   if call_positiony(1) > 192 then call_locate(1,1,call_positionx(1) + 1)
   tt = timer()  
  endif
  ti_sync()
  a$ = inkey$()
  if a$ <> ""
   call_motion(1,0,0)
   call_locate(1,96,128)
   call_pauseanimatedsprite(1)
   exit
  endif
 loop
return

Go back to ...

TI99E Commands Menu
Main Menu

Copyright © Carlos Santiago Lebron - TI99 Environment 2020