Accept at is an Extended BASIC command to take input from the user at a specific screen location. It can be emulated in TI Basic.
In Extended Basic you could use:
50 ACCEPT AT(10,12):A$
which would accept a string variable input at screen location row 10, column 12. To do this in TI Basic we have to write our own routine. That is the subject of this article.
In TI BASIC you need to use the routine below (lines 100 onwards) plus (for example):
53 GOSUB 100
54 GOTO 54
See below program for more details of how it works.
REMINDER: Set R & VR to desired row-column The input is placed in variable IN$ Use GOSUB to enter this routine when it is required note: Remove line 160 if you do not wish to be limited to entry of numbers 0 to 9.
110 CALL KEY(0,K,S)
120 CALL HCHAR(R,VR,30)
130 CALL HCHAR (R,VR,32)
140 IF S<1 THEN 110
150 IF K=13 THEN 250
160 IF (K<48)+(K>57) THEN 110
170 CALL HCHAR(R,VR,K)
190 IF VR<33 THEN 230
220 GOTO 250
230 IN$=IN$& CHR$(K)
240 GOTO 110
250 IF IN$="" THEN 110
The above program is an ACCEPT AT routine in TI BASIC. Using similar principles you can develop a PRINT AT routine.
Why do we need an ACCEPT AT routine?
The usual INPUT command causes the screen to scroll, and in the middle of a game with a complex screen display that can be disruptive!
The required routine will allow you to fill a variable string and place the input onto any desired part of the screen.
The initial screen location is held in the variables R(row) and VR(column).
The required input is to be placed in a string variable IN$. To ensure the variable is 'empty' it is cleared at the start of the routine.
The string is filled by means of a series of CALL KEYs, terminated with the ENTER key (which gives a code of 13).
For user confidence the cursor (character 30) is flashed at the position the input will appear at. This comes immediately after the call key. If required a CALL SOUND could be inserted just before the CALL KEY to provide the usual 'input' tone.
If no key is pressed, the cursor will just flash.
When a key is pressed, a check is made to see if it is the ENTER key, to terminate input (Key code 13). If ENTER has not been pressed, you can check to ensure the key falls within a required range.
In the sample given, only the number keys 0 to 9 are accepted as inputs (ASCI codes 48 to 57). If the choice of keys is not so neatly in sequence, you may use:
IF POS("ESDX",CHR$(S),1)<1 THEN 110
If the key pressed is not E, S, D or X in this example, the key is not accepted and the program returns to the CALL KEY.
If the key IS accepted, the letter is placed on the screen in the appropriate location, and the value of the column is increased by one.
A check is then made to see if the input has gone past the end of the screen : if no check was made, a BAD VALUE would be possible.
In this example, if the column exceeds a value of 33, it is reset to 32 and an automatic ENTER is inserted to terminate the input. You may prefer to substitute GOTO 110 instead of ending the input : this alternative places the cursor back on the last position (eg at screen right).
If the key is accepted, the character the key represents is added to the input string and the program returns to the CALL KEY.
Once ENTER has been pressed, a check is made to see if an input HAS been made (a nul input string could cause your program to crash). If no entry has been made the program returns to the CALL KEY.
If all is well, you are allowed to RETURN to the place in your program you left with a GOSUB. The input now lies in variable string IN$ for you to manipulate as you wish.
As the example program has limited the input to a string, a numeric variable can be set by using N=VAL(IN$) in your program.