bas7ex.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 Statements Programming Example
                       Example                 Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
'This example uses the TIMER and ON TIMER statements to enable timer event
'trapping. The program draws a polygon with a random shape, size, and
'location every three seconds.
 
SCREEN 1
DEFINT A-Z
DIM X(6), Y(6)
TIMER ON                      'Enable timer event trapping.
ON TIMER(3) GOSUB Drawpoly    'Draw a new polygon every
                              'three seconds.
PRINT "Press any key to end program"
INPUT "Press <RETURN> to start",Test$
 
DO
LOOP WHILE INKEY$ = ""        'End program if any key pressed.
 
END
 
Drawpoly:
   CLS                        'Erase old polygon.
   N = INT(5 * RND + 2)       'N is random number from 2 to 6.
   FOR I = 0 TO N
      X(I) = INT(RND * 319)   'Get coordinates of vertices of
      Y(I) = INT(RND * 199)   'polygon.
   NEXT
   PSET (X(N), Y(N))
   FOR I = 0 TO N
      LINE -(X(I), Y(I)),2    'Draw new polygon.
   NEXT
   RETURN