'=========================================================================== ' Subject: DELAY ROUTINE Date: 03-29-99 (23:21) ' Author: Nick Kochakian Code: QB, QBasic, PDS ' Origin: nickk@worldnet.att.net Packet: DATETIME.ABC '=========================================================================== 'DELAY1.BAS ' 'This program should provide a good enough base to write some sufficient 'delay routines. (Note: If you want to use this in a game, i'd strongly ' recommend that you adjust to frame rates.. Just an idea :) ' ' '3/29/99 By: - Nick Kochakian - 'web: http://come.to/dn3 'e-mail: nickk@worldnet.att.net DIM Timer.Whole.Second AS LONG 'This is where we store the result of the 'second. DIM Timer.Half.Second AS LONG DIM Timer.Quater.Second AS LONG Timer.Flag = 0 'Tells when to break out of the loop Timer.Whole.Second = 0 TIMER ON 'Turn the timer on ON TIMER(1) GOSUB Timer.Release: PRINT "Timing second..." DO Timer.Whole.Second = Timer.Whole.Second + 1 LOOP WHILE Timer.Flag = 0 Timer.Half.Second = Timer.Whole.Second / 2 Timer.Quarter.Second = Timer.Half.Second / 2 'Some example: CLS PRINT "I have known for some time now that timing in QBasic has been a" PRINT "problem. Which is why I've whiped up some basic timer routines." PRINT "This demo program will show you the differences between pausing" PRINT "for a Qtr second , and a half second." PRINT "" PRINT "Press SPACE" DO LOOP UNTIL INKEY$ = CHR$(32) CLS PRINT "Timing 3 times..." PRINT "" FOR t = 1 TO 3 FOR Timer.count = 1 TO Timer.Quarter.Second NEXT Timer.count PRINT ".25 seconds" NEXT t FOR t = 1 TO 3 FOR Timer.count = 1 TO Timer.Half.Second NEXT Timer.count PRINT ".5 seconds" NEXT t FOR t = 1 TO 3 FOR Timer.count = 1 TO Timer.Whole.Second NEXT Timer.count PRINT "1 second" NEXT t END Timer.Release: Timer.Flag = 1 TIMER OFF RETURN