Page 1 of 1

Need some TIMER help

Posted: Sat Jan 27, 2007 8:33 pm
by SCC
I'm still working on the QBasic Bootcamp tut series,
and on section 7, it says i need to count from 1 to 10
by printing the numbers 1 every second using the timer
command and a for/next loop. Well...i've tried several
times, and i can't figure it out. What i have here should
work, i see no reason why it wouldnt. What am i doing
wrong here?

Code: Select all

CLS
START = TIMER

DO
FOR T = 1 TO 10
	Sec% = INT(TIMER - START)

	IF Sec% > T THEN PRINT T
		IF T = 10 THEN GOTO 100
NEXT T
LOOP

100 END

Posted: Sun Jan 28, 2007 10:56 am
by nkk_kan
Do you mean this?

Code: Select all

Start! = timer

For i = 1 to 10 step 1
          sec% = Timer - start!
          Sleep 1
          Print Sec%
Next

Posted: Sun Jan 28, 2007 11:59 am
by SCC
Yeah...that works, but i think the tut author wanted it to be done just by the TIMER command. But i'm too frustrated with it to keep trying. SLEEP is the only way i could figure it out, too, so that's what he's getting, lol.
I need to move on to more tuts and start learning some cool stuff.

Posted: Tue Jan 30, 2007 1:52 pm
by Quibbler
tt=timer
for t=1 to 10
while timer-tt<t:wend
print t
next t

Posted: Fri Feb 02, 2007 4:23 am
by nkk_kan
here i got it properly :D

Code: Select all

For i = 0 to 10 step 1
       Delay 1
       Print i
Next

Sub delay(Dlay!)
Stime! = timer
Do
Loop while Timer - stime! < Dlay!
End sub


Posted: Fri Feb 02, 2007 12:19 pm
by SCC
wow cool :) Thnx for all the help. I put all 3 of these in one file so they run one after another, lol.