'=========================================================================== ' Subject: SLEEP REPLACEMENT Date: 06-30-92 (00:00) ' Author: Steve Halko Code: QB, QBasic, PDS ' Keys: SLEEP,REPLACEMENT Packet: DATETIME.ABC '=========================================================================== 'NEWSLEEP.BAS by Steve Halko, 6-30-92 DEFINT A-Z DECLARE FUNCTION ReadTimer& () DECLARE SUB NewSleep (Ticks) CALL NewSleep(18) 'Delay for 1 second or until key pressed CALL NewSleep(0) 'Delay until key pressed SUB NewSleep (Ticks) 'This function is a replacement for SLEEP. It takes the number 'of system clock ticks as an argument, which gives you much 'finer control than QB's SLEEP. To emulate SLEEP with no arguments, 'use NewSleep(0). Unlike SLEEP, key presses are cleared from the 'keyboard buffer. StopTime& = ReadTimer& + Ticks DO UNTIL ((ReadTimer& > StopTime&) AND Ticks) OR LEN(INKEY$) LOOP END SUB FUNCTION ReadTimer& STATIC '[]=============================================================[] '[] Returns the number of clock ticks since midnight '[] without invoking FP emulator like TIMER does '[]=============================================================[] DEF SEG = &H40 Lo& = PEEK(&H6C) + 256& * PEEK(&H6D) Hi& = PEEK(&H6E) + 256& * PEEK(&H6F) ReadTimer& = (65536 * Hi&) + Lo& END FUNCTION