BBC BASIC for Windows
« WAIT Command without halting? »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 11:10pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: WAIT Command without halting?  (Read 853 times)
Usama Amin
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 18
question WAIT Command without halting?
« Thread started on: Oct 21st, 2012, 09:20am »

hi again guys,
is there a way to make a specific part of the program wait without halting the whole program...
https://www.dropbox.com/s/y9a9fkhy0qirmek/Space%20Invaders.bbc
this is my program,
i am talking about line 450 to 520.
Thanks again
User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
question Re: WAIT Command without halting?
« Reply #1 on: Oct 21st, 2012, 3:05pm »

on Oct 21st, 2012, 09:20am, Usama Amin wrote:
is there a way to make a specific part of the program wait without halting the whole program...

Usually only a small delay, for example WAIT 0 or WAIT 1, is sufficient to keep your program's CPU usage low and allow other processes to run. Then you can check for a certain time having elapsed by, for example, testing the TIME pseudo-variable:

Code:
      Task1% = TIME
      Task2% = TIME
      REPEAT
        WAIT 1 : REM Release the CPU to other processes
        IF (TIME - Task1%) > 100 THEN
          Task1% = TIME
          REM Put here things which need to be done
          REM once every second
        ENDIF
        IF (TIME - Task2%) > 10 THEN
          Task2% = TIME
          REM Put here things which need to be done
          REM ten times every second
        ENDIF
      UNTIL FALSE 

Other ways you can tackle this are to use the ON TIME interrupt or the TIMERLIB library.

Richard.
User IP Logged

Usama Amin
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 18
question Re: WAIT Command without halting?
« Reply #2 on: Oct 21st, 2012, 3:25pm »

Thanks again richard smiley
User IP Logged

Usama Amin
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 18
question Re: WAIT Command without halting?
« Reply #3 on: Oct 21st, 2012, 3:30pm »

So if i used:

Task1% = TIME
Task2% = TIME
REPEAT
WAIT 1 : REM Release the CPU to other processes
IF (TIME - Task1%) > 100 THEN
Task1% = TIME
PRINT "hello"
ENDIF
UNTIL FALSE

It would print hello once every second?
User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
question Re: WAIT Command without halting?
« Reply #4 on: Oct 21st, 2012, 5:02pm »

on Oct 21st, 2012, 3:30pm, Usama Amin wrote:
So if i used [code snipped] It would print hello once every second?

Why are you asking when it takes only a moment to try it? One of the advantages of an interpreted language like BBC BASIC is that you get instant results - copy-and-paste the code into the BB4W editor and click 'Run'!

Richard.
User IP Logged

Usama Amin
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 18
question Re: WAIT Command without halting?
« Reply #5 on: Oct 21st, 2012, 5:03pm »

It didnt work sad
User IP Logged

Usama Amin
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 18
question Re: WAIT Command without halting?
« Reply #6 on: Oct 21st, 2012, 5:04pm »

Sorry,
Task1% = TIME
Task2% = TIME
REPEAT
WAIT 1 : REM Release the CPU to other processes
IF (TIME - Task1%) > 100 THEN
Task1% = TIME
PRINT "hello"
ENDIF
UNTIL FALSE
This worked but wehen i tried incorporating it in my program it didnt cry
User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx Re: WAIT Command without halting?
« Reply #7 on: Oct 21st, 2012, 9:26pm »

on Oct 21st, 2012, 5:04pm, Usama Amin wrote:
This worked but wehen i tried incorporating it in my program it didnt cry

I'm afraid that's your problem! Use the debugging tools available to you to find out why it's not working.

Richard.
User IP Logged

Usama Amin
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 18
question Re: WAIT Command without halting?
« Reply #8 on: Oct 22nd, 2012, 4:43pm »

I got it working thatnks for the advice Richard! grin
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls