Personal Computer News


Adding Single Key To The Amstrad

 
Published in Personal Computer News #093

Adding Single Key To To The Amstrad

When Locomotive Software wrote the Basic interpreter for the Amstrad it provided an entirely soft keyboard i.e. total control over what happens after each key is pressed. Different results are produced depending on whether the control or shift keys are pressed.

The following program provides the Amstrad with a set of 26 keywords using the KEY and KEY DEF commands. These are accessed by pressing the control key in conjunction with the first letter of the required keyword. This method of keyword entry is referred to as 'single key entry' and can speed up programming considerably.

Once run, the program will self-destruct so remember to save it to tape first. The 26 keywords are ones I use frequently including BORDER, WINDOW, VAL and PLOT. Of course, these can be replaced by words of your own choosing, but take care not to exceed the maximum total of 120 characters.

 10 ' Single key entry
 20 KEY DEF 15,1,48 :KEY DEF 13,1,49 :KEY DEF 14,1,50 :KEY DEF 5,1,51
 30 KEY DEF 20,1,52 :KEY DEF 12,1,53 :KEY DEF 4,1,54 :KEY DEF 10,1,55
 40 KEY DEF 11,1,56 :KEY DEF 3,1,57 :KEY DEF 6,1,13 :KEY DEF 7,1,46
 50 FOR char=128 TO 153
 60     READ KEY,NUMBER,EXP,CHAR$
 70     KEY DEF KEY,NUMBER,1,char-31,char-63,char
 80     KEY char,EXP,CHAR$
 90 NEXT char
100 DATA 69,"AUTO",54,"BORDER",62,"CHR$",61,"DRAW",58,"EDIT"
110 DATA 53,"FOR",52,"GOSUB",44,"HIMEM",35,"INPUT",45,"JOY"
120 DATA 37,"KEY",36,"LIST",38,"MOVE",46,"NEXT",34,"ORIGIN"
130 DATA 27,"PLOT",68,"TAB",50,"RETURN",60,"SOUND",51,"TEST"
140 DATA 42,"UPPER#",55,"VAL",59,"WINDOW",63,"XPOS",43,"YPOS"
150 DATA 71,"ZONE"
160 KEY DEF 6,1,13,13,154 :KEY 154,"RUN"+CHR$(34)+CHR$(13)
170 NEW

Jeffery Birks
Brixham, Devon

Jeffery Birks