TIMER function

Purpose: TIMER returns the number of seconds, one thousandth of a second resolution, since the current session of Windows started. This differs from other BASIC dialects which return the number of seconds since midnight.


 Syntax:

 RetVal! = TIMER

 Parameters:

  • RetVal! Number of seconds, one thousandth of a second resolution, since the current session of Windows started.

Example:


 DIM j%
 DIM start!
 DIM fini!
 DIM et!

 start! = TIMER
  FOR j% = 1 TO 1000000000
  NEXT j%
 fini! = TIMER

 et! = fini! - start!

 PRINT "Elapsed time" & STR$(et!) & " seconds"

BCX Console Sample Programs using TIMER function.

S40.bas   S95.bas   S135.bas  

Here is a related code snippet that uses the crt clock() function to detemine how many decimal seconds have elapsed from the time the program was started. This is used in the BCX translator to calculate how long it takes to translate a program.


 Elapsed! = ROUND((float)clock()/(float)CLOCKS_PER_SEC,2)