Specifications

Event Multitasking - 10
55 B$=KEYPAD$(0)
60 IF B$=CHR$(13) THEN ..Get_value
65 IF B$="*" THEN B$="."
70 A$=A$+B$
75 RETURN
80 ..Get_value
85 R=VAL(A$)
90 A$=""
95 RETURN
Line 30 tells CAMBASIC to call a subroutine by the name of “Keypad_interrupt” every time a key is
pressed.
Line 35 prints the number that the input string will be converted to. Initially, it will be zero.
Line 40 is a 0.25 second delay for demonstration purposes.
Line 45 is used only as part of this demo program so that the system will wait. You could insert the
rest of your control program.
Line 55 assigns the input to B$.
Line 60 tests to see if this is the terminator key for the input.
Line 65 tests to see if the input is an asterisk. If so, it converts it to a decimal point.
Line 70 adds the new value to the string.
Line 75 returns program execution to the place that it was executing before the key was pressed.
Line 85 converts the assembled string into a number.
Line 90 clear the assembled string to a null string.
Line 95 returns program execution to the place that it was executing before the key was pressed.
Fast Branching on Keys
Sometimes the input data is in the form of symbols. That is, rather than numbers and letters, the keypads legends might be
direction arrows or words like “Load” and “Stop”.
Intercepting these keys in the form of strings provides a slower response than using the key positions. The following
program does an instant branch to one of 16 routines, based on the position number.
10 'Branch on the Key Position
40 ON KEYPAD$ GOSUB ..Key_interrupt
50 GOTO 50
60 ..Key_interrupt
70 K=KEYPAD$(1)
80 ON K GOTO 100,200,300,400 ......,1600
90 RETURN
.
.
100 ..service key position 1
.
150 RETURN
.
200 'service key position 2
.