Difference between revisions of "TIMER"

From QB64 Wiki
Jump to navigation Jump to search
Line 9: Line 9:
  
 
''Example 2:''  
 
''Example 2:''  
 +
 
SUB Delay (dlay!)
 
SUB Delay (dlay!)
 +
 
start! = TIMER
 
start! = TIMER
 +
 
DO WHILE start! + dlay! >= TIMER
 
DO WHILE start! + dlay! >= TIMER
 +
 
IF start! > TIMER THEN start! = start! - 86400
 
IF start! > TIMER THEN start! = start! - 86400
 +
 
LOOP
 
LOOP
 +
 
END SUB
 
END SUB

Revision as of 04:21, 28 August 2009

TIMER returns the number of seconds past the previous midnite. It can return single values down to about .05 seconds accurately. Values range from 0 at midnite to 86399.

Example 1: t! = TIMER + 1: DO: LOOP UNTIL TIMER > t! 'one second delay

Warning: TIMER value comparison ranges cannot exceed 86399! If a comparison value is used it must fall within that range!

Example 2:

SUB Delay (dlay!)

start! = TIMER

DO WHILE start! + dlay! >= TIMER

IF start! > TIMER THEN start! = start! - 86400

LOOP

END SUB