Need some TIMER help

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
SCC
Coder
Posts: 12
Joined: Mon Oct 09, 2006 9:53 pm

Need some TIMER help

Post 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
nkk_kan
Veteran
Posts: 57
Joined: Thu Jun 01, 2006 10:45 am
Location: Gujrat,India,Asia
Contact:

Post 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
SCC
Coder
Posts: 12
Joined: Mon Oct 09, 2006 9:53 pm

Post 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.
User avatar
Quibbler
Coder
Posts: 16
Joined: Tue Jan 24, 2006 7:29 am
Location: Trinidad and Tobago

Post by Quibbler »

tt=timer
for t=1 to 10
while timer-tt<t:wend
print t
next t
nkk_kan
Veteran
Posts: 57
Joined: Thu Jun 01, 2006 10:45 am
Location: Gujrat,India,Asia
Contact:

Post 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

SCC
Coder
Posts: 12
Joined: Mon Oct 09, 2006 9:53 pm

Post 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.
Post Reply