Ontimer3.txt
Warning: if you clip this code into your program, look out for possible html code slipping in.
REM Example of ON TIMER REM Prints timer ticks between consecutive calls to REM a timer handler function. The function is called REM every count_time ticks of the system timer. REM Timer ticks are 10 ms GLOBAL hundredths AS INTEGER GLOBAL tmr_flag AS INTEGER GLOBAL time AS INTEGER GLOBAL last_hundredths AS INTEGER CONSTANT count_time AS INTEGER = 13 VITAL SUBROUTINE elapsed_time(x AS INTEGER) local temp as integer SET TIMER0 TO count_time hundredths=(DPEEK(14)+32767)/328 time=hundredths-last_hundredths IF time<0 time=100+time ENDIF last_hundredths=hundredths tmr_flag = 1 END print "\010\013" SET TIMER0 TO count_time ON TIMER0 elapsed_time DO WHILE 1 PRINT "\013\010",time," " DO WHILE tmr_flag = 0 REM LOOP tmr_flag = 0 LOOP