don`t use time$(), use timer, the timer tics 1000 times a second, so to do something every two seconds just get the current timer...
t=timer()
then add two seconds so that the variable t is two seconds larger than timer.....
t=t+2000
then inside the main loop just keep checking for the timer catching up with t....
if timer()>=t
note that we check for the timer being equal or greater (overshoot) than t, this is because in a real program some large calculation (say multiple collision tests) may mean that last time through the loop timer() was at t-1, then by the next loop it would be at t+1, if you just checked for it being equal then that would fail to trigger.
then inside the if-endif structure draw (as in your example) a box in a random colour and position
ink rgb(rnd(255),rnd(255),rnd(255)),0
x=rnd(600)
y=rnd(400)
w=rnd(200)+1
h=rnd(200)+1
box x,y,x+w,y+h
then reset the timer to start counting again, in this example I have assumed that just adding 2000 to t will suffice, if the action took a significant amount of time then this would show perceptable errors, but in this example the time lag will be not noticeable, although after drawing several thousand boxs the time may be out by one second from what it should be, but I have assumed this does not matter, never make code more elaborate than you need for the job in hand.
t=t+2000
then just end the decision structure
endif
heres the code made into a working example....
t=timer()
t=t+2000
do
if timer()>=t
ink rgb(rnd(255),rnd(255),rnd(255)),0
x=rnd(600)
y=rnd(400)
w=rnd(200)+1
h=rnd(200)+1
box x,y,x+w,y+h
t=t+2000
endif
loop
hope thats some help to you
Mentor.
PC1:XP, P4 3ghz, 1gig mem, 3x160gig hd`s, Radeon 9800pro, 6 way sound.
PC2: Linux, AMD 2ghz, 512mb ram, Nvidia GeForce4mx, 16 bit SB.
PC3: XP, laptop, intel 2.6ghz celeron, ATI 9000igp, 256mb