Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pause?
#1
I'm new to QBASIC, but I've done quite a bit (for a 14 year old w/ extra time in math class) of programming with a TI-83 calculator. Isn't that TI-BASIC? I'm just wondering if there's a PAUSE command where the application pauses (wow, that's why it's called PAUSE!) until the user hit's enter/any key, whichever is easier.

Any help?

I've seen TIMER around, how does this work?

I don't want something where I say wait 3 seconds then move on to the next task, I want it so the user can just hit enter and move on.
Reply
#2
It's called SLEEP. You can put a number afterwards to make it wait that many seconds or until a key is pressed.

That's only in 4.5 or above, so in 4.0 and lower, just do this: DO: LOOP UNTIL LEN(INKEY$)
am an asshole. Get used to it.
Reply
#3
WHILE INKEY$ = "": WEND
Reply
#4
TIMER is a function that returns the number of seconds that have passed since midnight (by your system clock's time). So you could go PRINT TIMER and you will get some value.

Uses of timer include:
  • Using it with the RANDOMIZE statement to create a 'random seed'. This makes numbers that QB generates with the RND statement well, more random than normal (but not completely random). eg:
    Code:
    FOR x = 1 to 10
      PRINT RND
    NEXT x

    Run this code a few times, and then run with a RANDOMIZE TIMER statement at the start, and you will see what I mean.
  • Using it to make a pause in a game for example that is always the same length on every computer regardless of speed. eg:
    Code:
    t# = TIMER
    WHILE t# + 2.5 > TIMER: WEND
    Will make a pause that is 2.5 seconds long on all computers.

I suggest you check out QBasic help if you have it, else download some tutorials on QBasic (reccomended), or, *gulp*, try the QBasicnews faq
Reply
#5
use to terminate the pause will generally not be discarded. Instead, it will be put into the keyboard buffer and the next process that looks for a keystroke will "see" that keystroke. That might not be what you want. If you use the Ctrl key to terminate the pause, you won't have that problem. The keystroke will just get ignored. (Just in case that matters.)
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Reply
#6
Or just clear the key buffer after the "sleep". [Image: vogel.gif]

while inkey$<>"":wend

reusing wizardlife's code.

BTW, don't forget the 86400!!! Check the FAQ! [Image: bigsquaregrin.gif]
img]http://usuarios.vtr.net/~disaster/sigs/annoyizer.php[/img]
Reply
#7
Yeah, I did link to the faq. BTW, what do you think of my plan for a Key Word Database? http://forum.qbasicnews.com/viewtopic.ph...62&start=7
Reply
#8
I don't think that it's "a must" since we have the mighty QBOHO, but if you have the time and the patience to build that in-deep database, well, you may become the nameless hero of a lot of newbies. [Image: biglaugh.gif]

Also, that's one of the points behind the WIKI system: if you think that it'll be useful, just post it and time will tell. [Image: naughty.gif]

As I stated before, and using again the memorable Capcom phrase: go for broke!
img]http://usuarios.vtr.net/~disaster/sigs/annoyizer.php[/img]
Reply
#9
Cool. I'll get cracking right away.

And if you think you know a thing or two about any key word, put it up. But kindly use the format that I will use.
Reply
#10
Hey, I started out on a TI-85 myself, The language is very similar to Qbasic.
When you want a program to pause, the easiest way is to just have the program ask for input and then just assign the keystroke as a dummy variable, such as:

INPUT pause

I use this all the time for debugging.



[/quote]
n a world as crazy as this one, it ought to be easy to find something that happens solely by chance. It isn't.

Kevin McKeen
The Orderly Pursuit of Pure Disorder.
Discover, January, 1981
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)