Searching help.

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

irascib1e
Coder
Posts: 10
Joined: Sat Oct 07, 2006 10:03 pm
Contact:

Searching help.

Post by irascib1e » Sat Oct 07, 2006 10:13 pm

For starters, I'm very new with QBasic.

In my school (I'm a sophmore in high school) I signed up for a computer programing class. We are learning about QBasic, and we are doing code in it. We are learning how to do very simple things though, like making programs that calculate GPA's and batting averages. This is somewhat confusing to me.

This same thing happened to me with flash.

Back in 7th grade, I took a course on an introduction to actionscript in Macromedia Flash. I found it very confusing, and I had a big test coming up so I searched for an online forum that is based around actionscript. From coming to this forum, I saw all the games made in actionscript which inspired me to learn. The people on these forums pointed me in the right direction to learning actionscript and whatnot. Next thing I knew, a week later, I was making games and was ahead of everybody in my class.

So it seems whenever there is something complicated with the computer that I need to learn, an online forum is the best place to go. I'm hoping the same thing here will happen with what happened in Flash. But now for a few questions:

What is a basic program or game that I should learn how to make, which will point me in the right direction to bigger and better programs?

What are some basic commands I should learn?

Thank you very much.
: D
:{D

bungytheworm
Veteran
Posts: 288
Joined: Sat Feb 18, 2006 4:02 pm

Post by bungytheworm » Sun Oct 08, 2006 3:32 am

You should learn all commands :wink:
Anyway, QBASIC is interesting and easy language. If you have some real interest to play with it, you should not have any problems on your way from noob to experienced one.

Even in this site, there is like 600 tutorials from where you can start learning.

I made 5 part beginners tutorial nearly 2 years ago. It's a bad english but it should be readeble. You can see them by goin www.ascii-world.com, selecting Beginner's Level from the menu left. There you can see lurah's Programming Basics Part X
Read those, i belieeve they help you a bit. Also lurah's Getting Familiar With Libraries and lurah's Logic Basics might be usefull to you.
Then just start wondering around this site to see those 600 tutorials. And if you get stuck with something, then ask help in here.

Welcome to wonderfull world of QB 8)

irascib1e
Coder
Posts: 10
Joined: Sat Oct 07, 2006 10:03 pm
Contact:

Post by irascib1e » Sun Oct 08, 2006 10:26 am

Thank you :)
:{D

nkk_kan
Veteran
Posts: 57
Joined: Thu Jun 01, 2006 10:45 am
Location: Gujrat,India,Asia
Contact:

Post by nkk_kan » Sun Oct 08, 2006 11:12 am

you might want to try "vic's Qbasic tutorials"
and Also Of "Dark Dread" (He wrote some nice tutors)
Google them and you will find them...

btW

WELCOME TO THE FORUM!!!!!! :D

irascib1e
Coder
Posts: 10
Joined: Sat Oct 07, 2006 10:03 pm
Contact:

Post by irascib1e » Sun Oct 08, 2006 11:24 am

^ thanks : D

by the way, how do you clear only a line in a command, but not the whole screen?

__________

Example:

PRINT "Hello, how are you?"
PRINT "Would you like some tea?"
___________

How would I clear "Hello, how are you?" without clearing "Would you like some tea?"? Is there a command to only clear one line without the other?
:{D

bungytheworm
Veteran
Posts: 288
Joined: Sat Feb 18, 2006 4:02 pm

Post by bungytheworm » Sun Oct 08, 2006 3:58 pm

As far as i know, there is no such a command.
But by using variables and locate, you can make one.
Show what you have done and we give you some hints how to move on. :wink:

irascib1e
Coder
Posts: 10
Joined: Sat Oct 07, 2006 10:03 pm
Contact:

Post by irascib1e » Sun Oct 08, 2006 5:03 pm

I'm going off your tutorial :D

Code: Select all

1
CLS
COLOR 14, 0
LOCATE 5, 1: PRINT "This program will tell you age differences between you and your family members."
LOCATE 6, 1: PRINT "5"
SLEEP 1
LOCATE 6, 1: PRINT "4"
SLEEP 1
LOCATE 6, 1: PRINT "3"
SLEEP 1
LOCATE 6, 1: PRINT "2"
SLEEP 1
LOCATE 6, 1: PRINT "1"
SLEEP 1
LOCATE 6, 1: INPUT "enter your name and press enter"; name$
LOCATE 7, 1: INPUT "enter your age and press enter"; age
CLS
LOCATE 15, 1: PRINT "Your name:"; name$
LOCATE 16, 1: PRINT "your age:"; age
LOCATE 6, 1: INPUT "enter your mother's name and press enter"; momname$
LOCATE 7, 1: INPUT "enter your mother's age and press enter"; momage
LOCATE 18, 1: PRINT "your mother's name:"; momname$
LOCATE 19, 1: PRINT "your mother's age:"; momage
LOCATE 6, 1: INPUT "enter your father's name and press enter:"; dadname$
LOCATE 7, 1: INPUT "enter your father's age and press enter:"; dadage
LOCATE 15, 30: PRINT "your father's name:"; dadname$
LOCATE 16, 30: PRINT "your father's age:"; dadage
LOCATE 6, 1: INPUT "enter your brother's name:"; brothername$
LOCATE 7, 1: INPUT "enter your brother's age:"; brotherage
LOCATE 18, 30: PRINT "your brother's name:"; brothername$
LOCATE 19, 30: PRINT "your brother's age:"; brotherage
Now you'll notice when you run the program that the new questions overlap the old ones. I was hoping for a command that would clear the old questions without erasing the print at the bottom.

EDIT///// Ok, I fixed that problem. I just did:

Code: Select all

PRINT "                                                                      "
It worked :D.

But now I have another problem.

The very end of my program says "Would you like to try this again?", and you can type yes or no to end, or do the program over.

Is there a way to make it so that if "yes" or "no" isnt typed, it will say "invalid answer"?

Here is the new program/////////

Code: Select all

1
CLS
COLOR 14, 0
LOCATE 5, 1: PRINT "This program will tell you age differences between you and your family members."
LOCATE 6, 1: PRINT "5"
SLEEP 1
LOCATE 6, 1: PRINT "4"
SLEEP 1
LOCATE 6, 1: PRINT "3"
SLEEP 1
LOCATE 6, 1: PRINT "2"
SLEEP 1
LOCATE 6, 1: PRINT "1"
SLEEP 1
LOCATE 6, 1: INPUT "enter your name and press enter"; name$
LOCATE 7, 1: INPUT "enter your age and press enter"; age
CLS
LOCATE 15, 1: PRINT "Your name:"; name$
LOCATE 16, 1: PRINT "your age:"; age
LOCATE 6, 1: INPUT "enter your mother's name and press enter"; momname$
LOCATE 7, 1: INPUT "enter your mother's age and press enter"; momage
LOCATE 6, 1: PRINT "                                                         "
LOCATE 7, 1: PRINT "                                                         "
LOCATE 18, 1: PRINT "your mother's name:"; momname$
LOCATE 19, 1: PRINT "your mother's age:"; momage
LOCATE 6, 1: INPUT "enter your father's name and press enter:"; dadname$
LOCATE 7, 1: INPUT "enter your father's age and press enter:"; dadage
LOCATE 6, 1: PRINT "                                                          "
LOCATE 7, 1: PRINT "                                                          "
LOCATE 15, 30: PRINT "your father's name:"; dadname$
LOCATE 16, 30: PRINT "your father's age:"; dadage
LOCATE 6, 1: INPUT "enter your brother's name:"; brothername$
LOCATE 7, 1: INPUT "enter your brother's age:"; brotherage
LOCATE 6, 1: PRINT "                                                           "
LOCATE 7, 1: PRINT "                                                            "
LOCATE 18, 30: PRINT "your brother's name:"; brothername$
LOCATE 19, 30: PRINT "your brother's age:"; brotherage
LOCATE 6, 1: PRINT "The difference of age between you and your mother are "; momage - age; "years."
SLEEP 2
LOCATE 7, 1: PRINT "The difference of age between you and your father are "; dadage - age; "years."
SLEEP 2
LOCATE 8, 1: PRINT "The difference of age between you and your brother are "; brotherage - age; "years."
SLEEP 2
LOCATE 10, 1: INPUT "Would you like to do this again?"; answer$
IF answer$ = "yes" THEN GOTO 1
IF answer$ = "yeah" THEN GOTO 1
IF answer$ = "sure" THEN GOTO 1
IF answer$ = "of course" THEN GOTO 1
IF answer$ = "yeap" THEN GOTO 1
IF answer$ = "no" THEN END
IF answer$ = "nope" THEN END
:{D

bungytheworm
Veteran
Posts: 288
Joined: Sat Feb 18, 2006 4:02 pm

Post by bungytheworm » Sun Oct 08, 2006 5:46 pm

EDIT///// Ok, I fixed that problem. I just did:

Code: Select all

PRINT "                                                                      " 
No, no, no. Keep on learning. Here is a hint. You need to get familiar with loops.

Code: Select all

DIM AS Integer Counter
DIM AS String TextString

TextString = "First text. You wana get riddof this??? We got to make this long one."
LOCATE 1,1 : Print TextString
SLEEP 2

' now get riddof that first text
For Counter = 1 TO LEN(TextString)
	LOCATE 1, Counter : Print CHR$(32);
Next Counter

TextString = "Second text."
LOCATE 1,2 : Print TextString
SLEEP
What comes on your "new" problem, learn you need to get familiar with IF...THEN...ELSE structures.

Code: Select all

IF result is yes
    print yes and do something else
ELSEIF result is no
    print no and do something else
ELSE print "invalid answer"

bungytheworm
Veteran
Posts: 288
Joined: Sat Feb 18, 2006 4:02 pm

Post by bungytheworm » Sun Oct 08, 2006 5:52 pm

Code: Select all

LOCATE 6, 1: PRINT "5"
SLEEP 1
LOCATE 6, 1: PRINT "4"
SLEEP 1
LOCATE 6, 1: PRINT "3"
SLEEP 1
LOCATE 6, 1: PRINT "2"
SLEEP 1
LOCATE 6, 1: PRINT "1"
SLEEP 1
This is good place to get familiar with loops.

Code: Select all

For Counter = 5 TO 1
     LOCATE 6, 1 : Print Counter
     SLEEP 1
Next Counter
MAke that replacement and youll see.

irascib1e
Coder
Posts: 10
Joined: Sat Oct 07, 2006 10:03 pm
Contact:

Post by irascib1e » Sun Oct 08, 2006 6:06 pm

I'm very confused with strings, as to what they are : /

Also, this:

Code: Select all

For Counter = 5 TO 1
     LOCATE 6, 1 : Print Counter
     SLEEP 1
Next Counter 
Didn't work :/

I might just be doing something wrong though, did I enter it right?

Code: Select all

1
CLS
COLOR 14, 0
LOCATE 5, 1: PRINT "This program will tell you age differences between you and your family members."
LOCATE 6, 1: PRINT "5"
SLEEP 1
For Counter = 5 TO 1
     LOCATE 6, 1 : Print Counter
     SLEEP 1
Next Counter 
LOCATE 6, 1: INPUT "enter your name and press enter"; name$
LOCATE 7, 1: INPUT "enter your age and press enter"; age
CLS
LOCATE 15, 1: PRINT "Your name:"; name$
LOCATE 16, 1: PRINT "your age:"; age
LOCATE 6, 1: INPUT "enter your mother's name and press enter"; momname$
LOCATE 7, 1: INPUT "enter your mother's age and press enter"; momage
LOCATE 6, 1: PRINT "                                                         "
LOCATE 7, 1: PRINT "                                                         "
LOCATE 18, 1: PRINT "your mother's name:"; momname$
LOCATE 19, 1: PRINT "your mother's age:"; momage
LOCATE 6, 1: INPUT "enter your father's name and press enter:"; dadname$
LOCATE 7, 1: INPUT "enter your father's age and press enter:"; dadage
LOCATE 6, 1: PRINT "                                                          "
LOCATE 7, 1: PRINT "                                                          "
LOCATE 15, 30: PRINT "your father's name:"; dadname$
LOCATE 16, 30: PRINT "your father's age:"; dadage
LOCATE 6, 1: INPUT "enter your brother's name:"; brothername$
LOCATE 7, 1: INPUT "enter your brother's age:"; brotherage
LOCATE 6, 1: PRINT "                                                           "
LOCATE 7, 1: PRINT "                                                            "
LOCATE 18, 30: PRINT "your brother's name:"; brothername$
LOCATE 19, 30: PRINT "your brother's age:"; brotherage
LOCATE 6, 1: PRINT "The difference of age between you and your mother are "; momage - age; "years."
SLEEP 2
LOCATE 7, 1: PRINT "The difference of age between you and your father are "; dadage - age; "years."
SLEEP 2
LOCATE 8, 1: PRINT "The difference of age between you and your brother are "; brotherage - age; "years."
SLEEP 2
LOCATE 10, 1: INPUT "Would you like to do this again?"; answer$
IF answer$ = "yes" THEN GOTO 1
IF answer$ = "yeah" THEN GOTO 1
IF answer$ = "sure" THEN GOTO 1
IF answer$ = "of course" THEN GOTO 1
IF answer$ = "yeap" THEN GOTO 1
IF answer$ = "no" THEN END
IF answer$ = "nope" THEN END 
When I try to put in the code for the whole "invalid answer" problem, it wont let me type it because it says there are errors.

Then again, I'm probably just going about it all wrong.
:{D

bungytheworm
Veteran
Posts: 288
Joined: Sat Feb 18, 2006 4:02 pm

Post by bungytheworm » Mon Oct 09, 2006 6:14 am

Sorry, it should be

Code: Select all

For Counter = 5 TO 1 STEP -1
     LOCATE 6, 1 : Print Counter
     SLEEP 1
Next Counter 
And these lines are useless ones

Code: Select all

LOCATE 6, 1: PRINT "5"
SLEEP 1 
I made you an example code about IF...THEN...ELSE structure. You need to modifie it to make it work on your program. Dont wana give finished code here.

Very simple one. If you press "y" then program prints "yes"
If you press "n" program prints "no".
In any other case, it prints "either"

Code: Select all

input a$
IF a$ = "y" then
	Print "yes"

ELSEIF a$ = "n" then 
	print "no"

ELSE 
	print "either"
ENDIF
sleep

irascib1e
Coder
Posts: 10
Joined: Sat Oct 07, 2006 10:03 pm
Contact:

Post by irascib1e » Mon Oct 09, 2006 3:54 pm

I understand everything except for this:

Code: Select all

input a$
IF a$ = "y" then
   Print "yes"

ELSEIF a$ = "n" then
   print "no"

ELSE
   print "either"
ENDIF
sleep
The whole IF ELSEIF ELSE thing dosen't make sense to me :/
:{D

User avatar
{Nathan}
Veteran
Posts: 1169
Joined: Thu Aug 19, 2004 6:08 pm
Location: The wetlands of central Ohio, USA
Contact:

Post by {Nathan} » Mon Oct 09, 2006 4:51 pm

It's simple.

Lets say X=2, and Y=4.

Code: Select all

IF X = 2 THEN
PRINT "This will show up because X is two"
ELSEIF Y=4 THEN
PRINT "This would show up if X did not equal 2."
ELSE
PRINT "If neither X=2  nor Y=4 then this will appear"
END IF
Basically, it checks if a condition is true, such as if X = 4, if MyString$ = "hello", etc. If CONDITION is TRUE, THEN it does the next line. If the condition is not ment, it goes through the ELSEIFS. They happed if no IFs/ELSEIFs before it are true. Then, it goes to ELSE last. If no conditions have been true, it does that. The IF/ELSEIF/ELSE block is closed with an END IF.
Image

bungytheworm
Veteran
Posts: 288
Joined: Sat Feb 18, 2006 4:02 pm

Post by bungytheworm » Mon Oct 09, 2006 5:23 pm

As nathan1993 sayd, if you wanan do something more than hello world one liner you need variables.

Variable is value.

a = 5
then a + a = 10?

a$ = text
then text + text = texttext= ;)

BASIC explanations:
Integer value of 1,2,3,4 or five. Any _full_ number (ok english gyus gimme a help wioth "full")

String can be some text. "lurah" is text, "i love you" is text...
So, text$ = "lurah" makes text$ + text$ = "lurahlurah"
Integer thing, a = 5
a + a = 10
You catch the difference ;) ?

Now we move it on real life.

Q: "Hi, is your name Chriss?"
If hes name is "Chriss" then say "Hi Chriss".

ELSEIF hes name is "Jesus" then say "Hi jesus"

ELSE say "Hi you not named as chriss or jesus"
ENDIF ' take this as end of interview.

If you have more problems please tell them, i bet more than i am willing to know and do some tutorials (ok, im searching topics to do em lol) for you and other noobs...(ok, i hate word noob)

irascib1e
Coder
Posts: 10
Joined: Sat Oct 07, 2006 10:03 pm
Contact:

Post by irascib1e » Mon Oct 09, 2006 7:23 pm

Whoa, that helped me so much.

Thanks guys, you're all being a great help right now :D
:{D

User avatar
Patz QuickBASIC Creations
Veteran
Posts: 399
Joined: Wed Mar 02, 2005 9:01 pm
Location: Nashville, Tennessee
Contact:

Post by Patz QuickBASIC Creations » Wed Oct 11, 2006 8:10 am

irascib1e wrote:by the way, how do you clear only a line in a command, but not the whole screen?
You could try:

Code: Select all

Locate Lin%,1:Print SPACE$(80)
where Lin% is equal to what line you want to clear. What it really does is print a line of 80 spaces, thus "clearing" the line.


Another thing you could do is:

Code: Select all

Print "Hello, how are you?";      'Be sure to place the semicolon!
SLEEP     'So the user can see the output before it gets erased.
Locate ,1:PRINT SPACE$(80)    'See note after code
PRINT "Would you like some tea?"
This prints "Hello, how are you?" and then waits for the user to press a key (SLEEP). The semicolon tells PRINT to make the next PRINT statement not to go to the next line, but to continue on the current line. Then, we clear the line as explained before, but using LOCATE ,1 to only move to the beginning of the current row. When the first arguement is omitted from LOCATE, it goes on the current line. And since we put the semicolon at the end of PRINT, the current line is the line where the first message is written. Then, we print our second message.



Hey, I have a challenge for a new programmer. Tell me if you can explain the logic behind this. Try executing the code, giving it different values for the text and line number. It is a commonly used piece of code by many BASIC programmers. It requires knowledge of strings ($), integers (%), LOCATE, PRINT, LEN, INT, and basic algebra.

Code: Select all

Input "Text: ", Tex$
Input "Line number: ", Lin%
LOCATE Lin%, 41-INT(LEN(Tex$)/2)
Print Tex$
Note: QBASIC help is your friend :)

User avatar
Patz QuickBASIC Creations
Veteran
Posts: 399
Joined: Wed Mar 02, 2005 9:01 pm
Location: Nashville, Tennessee
Contact:

Post by Patz QuickBASIC Creations » Wed Oct 11, 2006 8:15 am

lurah wrote:BASIC explanations:
Integer value of 1,2,3,4 or five. Any _full_ number (ok english gyus gimme a help wioth "full")
Any number without a decimal value.

EX.
5 is an integer.
-2 is an integer.
0 is an integer.
6.2 is NOT an integer.
-36.7 is NOT an integer.
0.5 is NOT an integer.

The INT function returns integers, which...
INT(0.4)=0
INT(3.2)=3
INT(47.9)=47
It trims off the decimal, instead of rounding it which is what most people expect it to do.

irascib1e
Coder
Posts: 10
Joined: Sat Oct 07, 2006 10:03 pm
Contact:

Post by irascib1e » Wed Oct 11, 2006 4:39 pm

Lurah, I tested myself to try to remake the game on your tutorial :P

It dosen't work though. Nothing prints after you input you guesses. Any help? I looked the code over a few times and compared it with the one on your tutorial and I didn't find any reason why it should not work.

Code: Select all

rounds = 0
points = 0

CLS
INPUT "What is your name"; name$

DO
CLS
INPUT "Enter your first guess (1-6)"; guess1
INPUT "Enter your second guess (1-6)"; guess2
guesstotal = guess1 + guess2

dice1 = INT(RND * 6 + 1)
PRINT "Dice 1 is"; dice1
IF guess1 = dice1 OR guess2 = dice1 THEN points = points + 1: PRINT "Congrats, you got dice1 right, you get a point!"
dice2 = INT(RND * 6 + 1)
PRINT "Dice 2 is "; dice2
IF guess1 = dice2 OR guess2 = dice2 THEN points = points + 1: PRINT "Congrats, you got dice2 right, plus 1 point!"
IF guesstotal = guess1 + guess2 THEN points = points + 1: PRINT "you got both guesses right, plus 1 point!"
rounds = rounds + 1
PRINT "You have played"; rounds; "rounds."
PRINT "You have "; points; "points."
LOOP UNTIL rounds > 10

CLS
PRINT "You got"; points; " points in a total of "; rounds; " rounds"
END
And I'll try your thing now, Patz :P.
:{D

irascib1e
Coder
Posts: 10
Joined: Sat Oct 07, 2006 10:03 pm
Contact:

Post by irascib1e » Wed Oct 11, 2006 9:36 pm

Ok, I fixed that problem.

I revised your game on your tutorial, Lurah.

(by the way, I did this ALL without looking at anything else in the backround. YAY ME!!)

One thing I was wondering. Is it possible to put a loop inside another loop?

I wanted to put the diceroll loop inside the game loop, so before each new round starts it rolls the die, but I coulden't figure it out.

Code: Select all

CLS
COLOR 4, 4
LOCATE 4, 11: PRINT "00000000000000000000000000"
LOCATE 5, 11: PRINT "00000000000000000000000000"
LOCATE 6, 11: PRINT "00000000000000000000000000"
LOCATE 7, 11: PRINT "00000000000000000000000000"
LOCATE 8, 11: PRINT "00000000000000000000000000"
LOCATE 9, 11: PRINT "00000000000000000000000000"
LOCATE 10, 11: PRINT "00000000000000000000000000"
LOCATE 11, 11: PRINT "00000000000000000000000000"  ' backround on dice
COLOR 6, 6
LOCATE 6, 14: PRINT "000"
LOCATE 7, 14: PRINT "0"
LOCATE 7, 17: PRINT "0"
LOCATE 8, 14: PRINT "0"
LOCATE 8, 17: PRINT "0"
LOCATE 9, 14: PRINT "000"
						   ' D
LOCATE 6, 19: PRINT "000"
LOCATE 9, 19: PRINT "000"
LOCATE 7, 20: PRINT "0"
LOCATE 8, 20: PRINT "0"                            ' I

LOCATE 6, 25: PRINT "000"
LOCATE 9, 25: PRINT "000"
LOCATE 7, 24: PRINT "0"
LOCATE 8, 24: PRINT "0"                            ' C

LOCATE 6, 30: PRINT "0000"
LOCATE 9, 30: PRINT "0000"
LOCATE 7, 30: PRINT "00"
LOCATE 8, 30: PRINT "0"

'                               START MENU
COLOR 8, 8
LOCATE 13, 11: INPUT "Press enter to begin"; wait$

'                               INTRO
CLS
LOCATE 6, 11: PRINT "I, computer, am about to roll a pair of cyber dice."
LOCATE 7, 11: PRINT "Your job is to guess the numbers the dice land on."
LOCATE 9, 11: INPUT "Before we can start, I need to ask your name"; name$
CLS
LOCATE 8, 11: PRINT "Well, good luck, "; name$; ". May luck be on your side."
LOCATE 10, 11: PRINT "I will roll the dice on your command."
LOCATE 11, 11: INPUT "Just press enter when you're ready"; wait2$
CLS

'                               GAME CODING
rounds = 0
points = 0
diceroll = 1
'                               DICEROOL LOOP
DO
diceroll = diceroll + 1
LOCATE 6, 11: PRINT "Rolling dice."
SLEEP 1
LOCATE 6, 11: PRINT "Rolling dice.."
SLEEP 1
LOCATE 6, 11: PRINT "Rolling dice..."
SLEEP 1
LOCATE 6, 11: PRINT "               "
LOOP UNTIL diceroll > 2
'                               GAME LOOP
DO
rounds = rounds + 1
LOCATE 6, 11: INPUT "What is your guess on the first die"; guess1
LOCATE 7, 11: INPUT "What is your guess on the second die"; guess2
guesstotal = guess1 + guess2

dice1 = INT(RND * 6 + 1)
LOCATE 9, 11: PRINT "The first die landed on"; dice1
IF dice1 = guess1 OR dice1 = guess2 THEN points = points + 1: LOCATE 10, 11: PRINT "You guessed the first die correctly. You earned one point."
dice2 = INT(RND * 6 + 1)
LOCATE 12, 11: PRINT "The second die landed on"; dice2
IF dice2 = guess1 OR dice2 = guess2 THEN points = points + 1: LOCATE 13, 11: PRINT "You guessed the second die correctly. You earned one point."
IF guesstotal = dice1 + dice2 THEN points = points + 1:  LOCATE 15, 11: PRINT "You guess both dice correctly. You get another point."
LOCATE 16, 11: PRINT "You played "; rounds; "rounds."
LOCATE 17, 11: PRINT "You have "; points; "points."
LOCATE 19, 11: INPUT "Press enter to go to the next round"; wait2$
CLS
LOOP UNTIL rounds > 9
CLS

LOCATE 6, 11: PRINT "You ended the game with a total of "; points; " in 10 rounds."
IF points > 10 THEN LOCATE 8, 11: PRINT "Very good, "; name$; "."
IF points < 10 THEN LOCATE 8, 11: PRINT "That score isn't too good, "; name$; "."
END
:{D

User avatar
Patz QuickBASIC Creations
Veteran
Posts: 399
Joined: Wed Mar 02, 2005 9:01 pm
Location: Nashville, Tennessee
Contact:

Post by Patz QuickBASIC Creations » Thu Oct 12, 2006 3:37 pm

irascib1e wrote:One thing I was wondering. Is it possible to put a loop inside another loop?
Yes, loops inside of loops are totally legal.

Code: Select all

FOR A=1 TO 24
FOR B=1 TO 80
PRINT A,B
SLEEP
NEXT B
NEXT A
What the code does (visual representation!)

Code: Select all

Start A loop
Start B loop
Print A,B
Increment B(+1)
Is B finally 80? If not, go back to the B loop start.
Increment A(+1)
Is A finally 24? If not, go back to the A loop start.
END OF THE CODE!
In fact, most programs bigger than a small size program use at least two loops inside one another...

Post Reply