When the time specified has passed, the subroutine is called automatically, just as if a GOSUB had
been issued at the current position in the program. When the subroutine finishes, using a normal
RETURN command, the main program continues running where it was interrupted.
The timers have different interrupt priorities. Timer 3 has the highest priority and timer 0 the
lowest.
AFTER commands may be issued at any time, resetting the subroutine and time associated with
the given delay timer. The delay timers are the same as those used in the EVERY command, so an
AFTER overrides any previous EVERY for the given timer, and vice versa.
10 MODE 1: X=0
20 AFTER 45 GOSUB 100
30 AFTER 100,1 GOSUB 200
40 PRINT "AMSOFT"
50 WHILE X<100
60 LOCATE #1,30,1:PRINT #1,X:X=X+1
70 WEND
80 END
100 PRINT "peripherals"
110 RETURN 110
200 PRINT "and software"
210 RETURN 210
Note the use of two streams (windows) to allow printing by the ‘main program’ (Lines 50-80) using
independant cursor positioning from that used by the interrupt subroutines.
AFTER the time you have preset in the command line, the program diverts to the designated
subroutine and performs the task defined therein:
10.2 EVERY
The EVERY command allows a BASIC program to arrange for subroutines to be called at regular
intervals. Four delay timers are available, each of which may have a subroutine associated with it.
Its form is:
EVERY <integer expression>, [<integer expression>] GOSUB <line number>
The first <integer expression> specifies how long to wait between each call of the subroutine. This
time is measured in 1/50ths of a second.
The second <integer expression> specifies which of the four possible delay timers is to be used. The
expression must yield a value in the range 0..3. If the expression is omitted, timer 0 is assumed.
When the time specified has passed, the subroutine is called automatically, just as if a GOSUB had
been issued at the current position in the program. When the subroutine finishes, using a normal
RETURN command, the main program continues running where it was interrupted.