Qbasicnews.com

QBasic => QB Discussion & Programming Help => Topic started by: Demon Red Storm on June 12, 2008, 07:06:10 PM



Title: Question about time
Post by: Demon Red Storm on June 12, 2008, 07:06:10 PM
My question is this: what is the command to pause the computer's execution of a program for a certain number of cycles, if it exists? I want to create scrolling text, but this is the only roadblock. I don't want it to be in intervals of seconds, so using time$ will not work, as far as I know of. I read a little, and the TIMER function instead seems appropriate, but I am not sure yet. I am using QBasic 7.1 to program this, in case that is necessary at all.


Title: Re: Question about time
Post by: LPG on June 13, 2008, 12:38:33 AM
there are a few solutions for this problem.
this one works slow on slow computers and fast on fast computers.

Code:
for a = 1 to number : next a

where number is a number. a big number will cause a big rest.

you can also use timer

Code:
t = timer
do
loop until timer > t + interval

where interval is the number of seconds? or milliseconds? to wait. this does not work if you run the program over midnight as timer returns the number of seconds\milliseconds? elapsed since midnight


Title: Re: Question about time
Post by: LPG on June 13, 2008, 05:13:40 AM
you can also use this:

Code:
WAIT &H3DA, 8

i got it from http://www.acidworks.com

it waits until the screen is refreshed and can be used in animation to reduce flickering.


Title: Re: Question about time
Post by: LPG on June 13, 2008, 05:45:27 AM
this does timing of nineteenths of a second. i got it from the same site:

Code:
SUB DELAY (time%)
    DEF SEG = 0
    POKE (1132), 0
   CountDown:
    IF PEEK(1132) < time% THEN GOTO CountDown
    DEF SEG
END SUB


Title: Re: Question about time
Post by: Demon Red Storm on June 13, 2008, 02:22:43 PM
K. Thanks for that. The only time I required a delay was an analog clock (like a grandfather clock) program I was working on. I think I can work around the "number of seconds and midnight" thing. It is the easiest syntax, as far as I can tell.

Anyway, please consider this closed. If you have another method, feel free to post it. However, I have all the information I need, as far as I know of. Thank you LPG, and any additional posters. Decided to leave this completely.