TIMER Sometimes Returns Number One Less Than Previous Value (20551)



The information in this article applies to:

  • Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0
  • Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0b

This article was previously published under Q20551

SUMMARY

There is a problem in the Macintosh ROM (both 64K and 128K ROMs) that, every one to five minutes, causes the TIMER function in QuickBASIC or BASIC to return a number that is one less than the previous value.

MORE INFORMATION

The following program demonstrates this ROM problem:
     Loop:  Newtime=TIMER
     IF Newtime < Oldtime THEN GOSUB Ouch
     Oldtime=Newtime
     GOTO Loop
     Ouch:  BEEP
     PRINT "Newtime",Newtime,"Oldtime",Oldtime
     PRINT "Timer",TIMER
     RETURN
				
To duplicate the problem, run this program for ten minutes. The subroutine should print only when the TIMER wraps around from the highest value back to zero, but instead, it prints every one to five minutes when TIMER mistakenly returns a number that is one less than the previous value of TIMER. The problem is in the Macintosh ROM routine Readdatetime that is called by TIMER. The problem may have to do with a software/hardware clock updating idiosyncrasy in Readdatetime.

This behavior is not due to a fault in QuickBASIC or BASIC; it is an Apple Macintosh ROM problem.

To work around the problem, you can use PEEK(527), which counts from 0 to 255 by seconds, or use ON TIMER(1) GOSUB and increment a second counter.

Modification Type:MajorLast Reviewed:10/20/2003
Keywords:KB20551