ex.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
TIMER Function Example
                        Example                Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
' This example searches for the prime numbers from 3 to 10,000 using
' a variation of the Sieve of Eratosthenes. The TIMER function is used
' to time the program.
 
' To try this example:
' 1. Choose New Project from the File menu
' 2. Copy the code example below to the code window
' 3. Press F5 to run the example
 
 DEFINT A-Z
 CONST UNMARK = 0, MARKIT = NOT UNMARK
 DIM Mark(10000)
 
 CLS                              ' Clear the screen
 Start! = TIMER
 Num = 0
 FOR N = 3 TO 10000 STEP 2
     IF NOT Mark(N) THEN
          'PRINT N,               ' To print the primes, remove the
                                  ' remark delimiter in front of the
                                  ' PRINT statement
          Delta = 2 * N
          FOR I = 3 * N TO 10000 STEP Delta
               Mark(I) = MARKIT
          NEXT
          Num = Num + 1
     END IF
 NEXT
 Finish! = TIMER
 PRINT
 PRINT "Program took"; Finish! - Start!;
 PRINT "seconds to find the"; Num; "primes"
 END