New to QB 4.5
Burger. Thanks for the input. I've switched to a desktop and I seem to have non-BASIC programming problems with it. I'll go back to the laptop I wrote the program on and check it out. I'll get back to you.
Those are the only two sounds I've tried.
Those are the only two sounds I've tried.
'Knowledge.bas
CLS
PRINT "Half of knowledge is knowing where to find it"
SLEEP 60
CLS
PRINT "Half of knowledge is knowing where to find it"
SLEEP 60
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
If you are getting sounds it probably has something to do with the calling procedures enabling the GOSUB procedures.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
Sound Problem Solved
My thanks to burger227 for the help. My problem was in my GOSUB procedures. I changed my formatting from this:burger2227 wrote:If you are getting sounds it probably has something to do with the calling procedures enabling the GOSUB procedures.
wrong:
IF sound$ = "n" THEN LOCATE 22, 22: PRINT "You have the sound turned off.";
RETURN
BEEP
BEEP
RETURN
To this:
wrong:
IF sound$ = "n" THEN
LOCATE 22, 22: PRINT "You have the sound turned off.";
RETURN
ELSE
BEEP
BEEP
RETURN
END IF
And now the sound is just fine. (My desktop wasn't the problem at all.)
I've decided to set this one aside for now and to move on to another project - haven't yet decided what.
Now you know why I say: "Half of knowledge is knowing where to find it."
'Knowledge.bas
CLS
PRINT "Half of knowledge is knowing where to find it"
SLEEP 60
CLS
PRINT "Half of knowledge is knowing where to find it"
SLEEP 60
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
You could use a colon to combine commands in the IF statement too:
Code: Select all
wrong:
IF sound$ = "n" THEN LOCATE 22, 22: PRINT "You have the sound turned off."; : RETURN
BEEP
BEEP
RETURN
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
This is the format I initially had except with the 1st return in a separate line, and the sound wouldn't work. Go figure.burger2227 wrote:You could use a colon to combine commands in the IF statement too:
Code: Select all
wrong: IF sound$ = "n" THEN LOCATE 22, 22: PRINT "You have the sound turned off."; : RETURN BEEP BEEP RETURN
![Evil or Very Mad :evil:](./images/smilies/icon_evil.gif)
'Knowledge.bas
CLS
PRINT "Half of knowledge is knowing where to find it"
SLEEP 60
CLS
PRINT "Half of knowledge is knowing where to find it"
SLEEP 60
Here I go again - with another one
This program generates a number from two through twelve, simulating the roll of dice. You get to guess the number rolled; get it right and you can try again. Miss it ten times in a row and the game is over.
The program starts by popping up "ROLL THE DICE" one letter at a time but the way I did it seems inefficient. I wonder if there is a more efficient way, say using a DATA statement. The coding of the entire program is copy/pasted below but here is the part I'm wondering about:
LOCATE 5, 21: PRINT "Let's ..."
GOSUB pause: LOCATE 5, 31: PRINT "R " 'pause makes a one-second pause
GOSUB pause: LOCATE 5, 33: PRINT "O "
GOSUB pause: LOCATE 5, 35: PRINT "L "
GOSUB pause: LOCATE 5, 37: PRINT "L "
GOSUB pause: LOCATE 5, 40: PRINT "T "
GOSUB pause: LOCATE 5, 42: PRINT "H "
GOSUB pause: LOCATE 5, 44: PRINT "E "
GOSUB pause: LOCATE 5, 47: PRINT "D "
GOSUB pause: LOCATE 5, 49: PRINT "I "
GOSUB pause: LOCATE 5, 51: PRINT "C "
GOSUB pause: LOCATE 5, 53: PRINT "E "
You can download the program from my website at quickbasic64.weebly.com.
The program starts by popping up "ROLL THE DICE" one letter at a time but the way I did it seems inefficient. I wonder if there is a more efficient way, say using a DATA statement. The coding of the entire program is copy/pasted below but here is the part I'm wondering about:
LOCATE 5, 21: PRINT "Let's ..."
GOSUB pause: LOCATE 5, 31: PRINT "R " 'pause makes a one-second pause
GOSUB pause: LOCATE 5, 33: PRINT "O "
GOSUB pause: LOCATE 5, 35: PRINT "L "
GOSUB pause: LOCATE 5, 37: PRINT "L "
GOSUB pause: LOCATE 5, 40: PRINT "T "
GOSUB pause: LOCATE 5, 42: PRINT "H "
GOSUB pause: LOCATE 5, 44: PRINT "E "
GOSUB pause: LOCATE 5, 47: PRINT "D "
GOSUB pause: LOCATE 5, 49: PRINT "I "
GOSUB pause: LOCATE 5, 51: PRINT "C "
GOSUB pause: LOCATE 5, 53: PRINT "E "
You can download the program from my website at quickbasic64.weebly.com.
'Knowledge.bas
CLS
PRINT "Half of knowledge is knowing where to find it"
SLEEP 60
CLS
PRINT "Half of knowledge is knowing where to find it"
SLEEP 60
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
1) Use larger text in your posts so older people can read them too.
2) Try using a FOR loop with MID$ to scroll through the text. Repetitive tasks are what loops are for and they make coding a lot easier:
You can send any text to the SUB the same way. You can even locate it by sending those coordinates in the call too.
You can use a TIMER delay loop instead of SLEEP to do it slightly faster, but user cannot speed up.
2) Try using a FOR loop with MID$ to scroll through the text. Repetitive tasks are what loops are for and they make coding a lot easier:
Code: Select all
Scroll "ROLL THE DICE"
END
SUB Scroll (text$)
LOCATE 10, 10 'locates start of text print
FOR i = 1 TO LEN(text$)
letter$ = MID$(text$, i, 1)
PRINT letter$; 'semicolon keeps print on same line
SLEEP 1 'allows user to hold a key down to hurry up prints
NEXT
DO: K$ = INKEY$: LOOP UNTIL K$ = "" 'clears key buffer if used during SLEEP
END SUB
You can use a TIMER delay loop instead of SLEEP to do it slightly faster, but user cannot speed up.
Code: Select all
Scroll "ROLL THE DICE", 10, 10
END
SUB Delay (dlay!)
start! = TIMER
DO WHILE start! + dlay! >= TIMER
IF start! > TIMER THEN start! = start! - 86400
LOOP
END SUB
SUB Scroll (text$, row, column)
LOCATE row, column 'locates start of text print
FOR i = 1 TO LEN(text$)
letter$ = MID$(text$, i, 1)
PRINT letter$; 'semicolon keeps print on same line
Delay .5 'half second delay or use _DELAY in QB64
NEXT
END SUB
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
Thanks burger2227
I'll be working on your suggestions.
'Knowledge.bas
CLS
PRINT "Half of knowledge is knowing where to find it"
SLEEP 60
CLS
PRINT "Half of knowledge is knowing where to find it"
SLEEP 60
More
Further, I guess I like your first version better because it seem more compact. However, both work just fine.
'Knowledge.bas
CLS
PRINT "Half of knowledge is knowing where to find it"
SLEEP 60
CLS
PRINT "Half of knowledge is knowing where to find it"
SLEEP 60
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
The second one uses a TIMER Delay sub in Qbasic. It can do delays down to .05 seconds or 1/18th of a second. If you use Delay.2 in the Scroll SUB it will look like it is typed in.
The advantage of using TIMER delays and loops is that your program will always run the same speed on any computer no matter how fast it is.
The SUB programs can be called anywhere you need them at any time just like GOSUB procedures, but you have to pass the variable values to them. GOSUB can use any values that exist in the main program module.
The advantage of using TIMER delays and loops is that your program will always run the same speed on any computer no matter how fast it is.
The SUB programs can be called anywhere you need them at any time just like GOSUB procedures, but you have to pass the variable values to them. GOSUB can use any values that exist in the main program module.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
Got it!
THANK YOU. ![Rolling Eyes :roll:](./images/smilies/icon_rolleyes.gif)
![Rolling Eyes :roll:](./images/smilies/icon_rolleyes.gif)
'Knowledge.bas
CLS
PRINT "Half of knowledge is knowing where to find it"
SLEEP 60
CLS
PRINT "Half of knowledge is knowing where to find it"
SLEEP 60
Re: New to QB 4.5
Well here I am again with another endeavor. It's another exercise in trivia but with different questions.
I gave up on the sound effects - for the present anyway. This time I tried to be more compact on my coding.
For example, instead of repeating the same long request for input, I put the request into a subroutine.
I also give the user the option of viewing the program in the smaller default QB64 window or in a full screen.
You can view a copy of the code and/or download the program from my website at http://www.quickbasic64.weebly.com.
As always I welcome your input.
I gave up on the sound effects - for the present anyway. This time I tried to be more compact on my coding.
For example, instead of repeating the same long request for input, I put the request into a subroutine.
I also give the user the option of viewing the program in the smaller default QB64 window or in a full screen.
You can view a copy of the code and/or download the program from my website at http://www.quickbasic64.weebly.com.
As always I welcome your input.
'Knowledge.bas
CLS
PRINT "Half of knowledge is knowing where to find it"
SLEEP 60
CLS
PRINT "Half of knowledge is knowing where to find it"
SLEEP 60
Re: New to QB 4.5
If you send me email at qbnovice@hushmail" target="_blank, it will kick back. The correct email is now qb64novice@hushmail.com" target="_blank" target="_blank.
I have tried several times to change it on the User Control Panel but it just keeps going back to the incorrect email.
I have tried several times to change it on the User Control Panel but it just keeps going back to the incorrect email.
'Knowledge.bas
CLS
PRINT "Half of knowledge is knowing where to find it"
SLEEP 60
CLS
PRINT "Half of knowledge is knowing where to find it"
SLEEP 60
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
Re: New to QB 4.5
I have fixed the issue. Did you notice that you had to enter it twice to confirm?
I also abbreviated your old address so nobody would try to use it by clicking on it.
You may want to remove the new address from your post if spammers use it.
I also abbreviated your old address so nobody would try to use it by clicking on it.
You may want to remove the new address from your post if spammers use it.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
Re: New to QB 4.5
Thank you very much for the help.
'Knowledge.bas
CLS
PRINT "Half of knowledge is knowing where to find it"
SLEEP 60
CLS
PRINT "Half of knowledge is knowing where to find it"
SLEEP 60