qb45advr.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.
ON TIMER(n) Statement Programming Example
◄QuickSCREEN► ◄Details► ◄Example► ◄Contents► ◄Index►
──────────────────────────────────────────────────────────────────────────────
ON TIMER(n) Statement Programming Example
Here is a program that draws a polygon every three seconds with a random
shape (three to seven sides), size, and location:
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