How to disable arrow keys

Everything related to BASIC version 1.x (Oric 1 and Atmos) or HYPERBASIC (Telestrat).
Don't hesitate to give your small program samples, technical insights, or questions...
Brana
Flying Officer
Posts: 169
Joined: Fri Nov 30, 2007 8:30 pm
Contact:

How to disable arrow keys

Post by Brana »

Hello, I wonder when using the INPUT statement, example:

10 INPUT"Please enter your name",A$

the user can use array keys (up/down/left/right) to move across the screen but I do not want that to happen!

So i wonder, is there anything to (example) POKE for, in order to disable UP/Down/Left/Right keys BEFORE issuing INPUT, and then POKE-it back in "normal" to enable it AFTER Input is complete?

Example:

10 Rem - Disable array keys (POKE???) or something?
20 INPUT ...
30 Rem - Enable back array keys (POKE?)
User avatar
Chema
Game master
Posts: 3013
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: How to disable arrow keys

Post by Chema »

I would be very surprised if there were a way to do this. I guess that, as the keypresses are handled by the ROM as part of the IRQ, you cannot patch into that, and I don't think they provided any RAM variable to handle that case.

I remember using KEY$/GET and loops to avoid other undesired behaviours of INPUT (the ? sign, bypassing some characters and others I can't remember), but guess that won't solve the problem of the arrows unless you keep placing the cursor back to the correct position at each loop iteration.

Surely you can use PRINT @ for that somehow, but I think I remember there were some variables in page 2 that cold cursor row and col positions... maybe you can toy with those and create your own input routine in basic?

Cheers
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug »

Chema is right, there's no way to change the default behavior of INPUT which after all only behave like in most other implementations in other BASICs.

The worse is for numbers. If you do "INPUT A", it will put a special error message if what you enter is not a number.

The best way is to use GET$

Code: Select all

10 PRINT"Please enter your name ";
20 A$=""
30 REPEAT
40 GET K$
50 IF (K$>="A" AND K$<="Z") OR (K$>="a" AND K$<="z") THEN A$=A$+K$:PRINT K$
60 IF K$=CHR$(127) THEN A$=LEFT$(A$,LEN(A$)-1)
70 UNTIL K$=CHR$(13)
(not tested)
Post Reply