TIMOUT / TIME
Supported by: COMX BASIC V1.00
The commands TIMOUT and TIME are used jointly to enable the programmer to call a subroutine after a specified lapse of time. The "alarm clock" is set by the command, TIME (X) where X is an integer. When the above instruction is executed, the "clock" starts ticking. When X units of time has elapsed, the command, TIMOUT Y is activated and the computer is directed to jump to a subroutine beginning with the line number Y. In the PAL version of the COMX-35, 50 units is equivalent to 1 second. In the NTSC version of the COMX-35, 60 units is equivalent to 1 second.
The typical structure of a program involving a time-controlled subroutine, and the sequence of actions are illustrated in Figure 1.
Step 1: The instruction TIMOUT 1000 is encountered. The computer takes note of the beginning address of the subroutine, but there is no other action as yet. The instruction TIME (150) is executed, and the "clock" is set to tick.
Step 2: The computer proceeds as usual.
Step 3: When 150 units of time (i.e. 3 seconds for PAL machines or 2.5 seconds for NTSC machines) have elapsed after the execution of statement 100, the "clock alarm" will cause the computer to jump to the beginning of the subroutine.
Step 4: The subroutine is being executed. It is usual to find the "clock" being set inside the subroutine but this is not mandatory. Statement 1990 shows that the "clock" is set to give an "alarm" after 100 units of time.
Step 5: Upon hitting RETURN, control is returned to statement 20 immediately after TIMOUT.
Step 6: The computer will proceed as usual until 100 units of time have elapsed after statement 1990, when again control is passed to the subroutine.