Page 2 of 2

Posted: Mon Apr 15, 2013 5:22 am
by Newbie
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.

Posted: Mon Apr 15, 2013 11:32 am
by Newbie
burger2227 wrote:You need to include the calls to those GOSUB programs.
I'm not sure what you mean by your comment. :?:

Posted: Mon Apr 15, 2013 2:10 pm
by burger2227
If you are getting sounds it probably has something to do with the calling procedures enabling the GOSUB procedures.

Sound Problem Solved

Posted: Tue Apr 16, 2013 1:56 pm
by Newbie
burger2227 wrote:If you are getting sounds it probably has something to do with the calling procedures enabling the GOSUB procedures.
My thanks to burger227 for the help. My problem was in my GOSUB procedures. I changed my formatting from this:

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."

Posted: Tue Apr 16, 2013 2:48 pm
by burger2227
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 

Posted: Tue Apr 16, 2013 3:05 pm
by Newbie
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 
This is the format I initially had except with the 1st return in a separate line, and the sound wouldn't work. Go figure. :evil: Please see my previous post.

Here I go again - with another one

Posted: Tue Apr 30, 2013 1:19 pm
by Newbie
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.

Posted: Tue Apr 30, 2013 1:53 pm
by burger2227
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:

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

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

Thanks burger2227

Posted: Tue Apr 30, 2013 7:32 pm
by Newbie
I'll be working on your suggestions.

More

Posted: Tue Apr 30, 2013 7:48 pm
by Newbie
Further, I guess I like your first version better because it seem more compact. However, both work just fine.

Posted: Wed May 01, 2013 3:55 am
by burger2227
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.

Got it!

Posted: Wed May 01, 2013 10:27 am
by Newbie
THANK YOU. :roll:

Re: New to QB 4.5

Posted: Mon Jul 22, 2013 1:42 pm
by Newbie
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.

Re: New to QB 4.5

Posted: Sun Sep 29, 2013 11:05 am
by Newbie
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.

Re: New to QB 4.5

Posted: Sun Sep 29, 2013 11:27 am
by burger2227
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.

Re: New to QB 4.5

Posted: Sun Sep 29, 2013 6:49 pm
by Newbie
Thank you very much for the help.