cannot maintain variables in the subs
Posted: Fri Dec 24, 2004 6:07 pm
I am creating a program in QBASIC and am stuck. Here is my program:
>
> DECLARE SUB ending ()
> DECLARE SUB menu ()
>
> CLS
> PRINT "Please select from the menu below any thing you wish to order (type the PRICE of the item you wish to order)"
> PRINT "An externel Floppy drive 46.99$"
> PRINT "An external CD-ROM drive 72.55$"
> PRINT "An external DVD-ROM drive 99.99$"
> PRINT "An external CD/DVD-ROM combo burner drive 255.68$"
> PRINT "50 blank 80 minute CD-ROMs 25.32$"
> PRINT "50 blank 100 minute CD-ROMs 32.25$"
> PRINT "50 blank 100 minute DVDs 100.00$"
> PRINT "50 blank floppies 25.55$"
> PRINT "300 sheets of recycled computer paper 2.99$"
> PRINT "300 sheets of computer cardstock 4.99$"
> PRINT "300 sheets of bright computer paper 3.50$"
> INPUT order%
> CLS
> PRINT "How much would you like (do not spell out numbers)"
> INPUT amount%
> PRINT "Would you like to order anything else?"
> INPUT wouldyou$
> IF wouldyou$ = "y" OR wouldyou$ = "Y" OR wouldyou$ = "yes" THEN menu
> INPUT order2%
>
> CLS
> PRINT "How much would you like (do not spell out numbers)"
> INPUT amount2%
> PRINT "Would you like to order anything else?"
> INPUT wouldyou$
> IF wouldyou$ = "y" OR wouldyou$ = "Y" OR wouldyou$ = "yes" THEN menu
> INPUT order3%
>
> CLS
> PRINT "How much would you like (do not spell out numbers)"
> INPUT amount3%
> PRINT "Would you like to order anything else?"
> INPUT wouldyou$
> IF wouldyou$ = "y" OR wouldyou$ = "Y" OR wouldyou$ = "yes" THEN menu
> INPUT order4%
>
> CLS
> PRINT "How much would you like (do not spell out numbers)"
> INPUT amount4%
> PRINT "Would you like to order anything else?"
> INPUT wouldyou$
> IF wouldyou$ = "y" OR wouldyou$ = "Y" OR wouldyou$ = "yes" THEN menu
> INPUT order5%
>
> CLS
> PRINT "How much would you like (do not spell out numbers)"
> INPUT amount5%
> PRINT "Would you like to order anything else?"
> INPUT wouldyou$
> IF wouldyou$ = "y" OR wouldyou$ = "Y" OR wouldyou$ = "yes" THEN menu
> INPUT order6%
>
> CLS
> PRINT "How much would you like (do not spell out numbers)"
> INPUT amount6%
> PRINT "Would you like to order anything else?"
> INPUT wouldyou$
> IF wouldyou$ = "y" OR wouldyou$ = "Y" OR wouldyou$ = "yes" THEN menu
> INPUT order7%
>
> CLS
> PRINT "How much would you like (do not spell out numbers)"
> INPUT amount7%
> PRINT "Would you like to order anything else?"
> INPUT wouldyou$
> IF wouldyou$ = "y" OR wouldyou$ = "Y" OR wouldyou$ = "yes" THEN menu
> INPUT order8%
>
> CLS
> PRINT "How much would you like (do not spell out numbers)"
> INPUT amount8%
> PRINT "Would you like to order anything else?"
> INPUT wouldyou$
> IF wouldyou$ = "y" OR wouldyou$ = "Y" OR wouldyou$ = "yes" THEN menu
> INPUT order9%
>
> CLS
> PRINT "How much would you like (do not spell out numbers)"
> INPUT amount9%
> PRINT "Would you like to order anything else?"
> INPUT wouldyou$
> IF wouldyou$ = "y" OR wouldyou$ = "Y" OR wouldyou$ = "yes" THEN menu
> INPUT order10%
>
> CLS
> PRINT "How much would you like (do not spell out numbers)"
> INPUT amount10%
> PRINT "Would you like to order anything else?"
> INPUT wouldyou$
> IF wouldyou$ = "y" OR wouldyou$ = "Y" OR wouldyou$ = "yes" THEN menu
> INPUT order11%
>
> CLS
> PRINT "How much would you like (do not spell out numbers)"
> INPUT amount11%
> price% = order% * amount%
> price2% = order2% * amount2%
> price3% = order3% * amount3%
> price4% = order4% * amount4%
> price5% = order5% * amount5%
> price6% = order6% * amount6%
> price7% = order7% * amount7%
> price8% = order8% * amount8%
> price9% = order9% * amount9%
> price10% = order10% * amount10%
> price11% = order11% * amount11%
> subtotal% = price% + price2% + price3% + price4% + price5% + price6% +
> price7% + price8% + price9% + price10% + price11% PRINT "total of this
> order "; price%
>
> PRINT "total of this order "; price2%
>
> PRINT "total of this order "; price3%
>
> PRINT "total of this order "; price4%
>
> PRINT "total of this order "; price5%
>
> PRINT "total of this order "; price6%
>
> PRINT "total of this order "; price7%
>
> PRINT "total of this order "; price8%
>
> PRINT "total of this order "; price9%
>
> PRINT "total of this order "; price10%
>
> PRINT "total of this order "; price11% PRINT PRINT "Your subtotal
> comes to:"
> PRINT subtotal%
> tax% = subtotal% * .0875
> PRINT "Your tax comes to:"
> PRINT tax%
> total% = subtotal% + tax%
> PRINT "Your total comes to:"
> PRINT total%
> PRINT "Press enter to continue"
> INPUT enter$
>
> CLS
> PRINT "Hello my name is compu. I am the computerized version of our buisness. I take over after you have made your order."
> SLEEP 25
> CLS
> PRINT "What is your full first name"
> INPUT name$
> SLEEP 1
> DO
> CLS
> PRINT "Hello "; name$; "!!!"
> SLEEP 2
> CLS
> PRINT name$; "You must take a short survey in order to purchase this product so we may have your information on file to send the product to you. Do you wish to continue"
> INPUT survey$
> IF survey$ = "N" OR survey$ = "n" OR survey$ = "no" THEN END
> CLS
> SLEEP 2
> PRINT "What is your middle name"
> INPUT middle$
> CLS
> SLEEP 1
> PRINT "What is your last name"
> INPUT last$
> CLS
> SLEEP 1
> PRINT "What is your address"
> INPUT address$
> CLS
> SLEEP 1
> PRINT "What city do you live in"
> INPUT city$
> CLS
> SLEEP 1
> PRINT "What state do you live in"
> INPUT state$
> CLS
> SLEEP 1
> PRINT "What is your zipcode"
> INPUT zipcode
> CLS
> SLEEP 1
> PRINT "What is your current age in years"
> INPUT years%
> CLS
> SLEEP 1
> PRINT "We are now processing your entry. Your cooperation has been appriciated. Please be patient."
> SLEEP 6
> CLS
> PRINT "Please check your information below:"
> PRINT "Your full name is "; name$; " "; middle$; " "; last$
> PRINT "You live at "
> PRINT ; address$
> PRINT city$; ", "; state$; " "; zipcode
> months% = years% * 12
> days% = years% * 365
> PRINT "You are "; years%; " years old"
> PRINT "You are "; months%; " months old"
> PRINT "You are "; days%; " days old"
> PRINT "Is this correct? (Y or N)"
> INPUT Answer$
> LOOP UNTIL Answer$ = "Y" OR Answer$ = "y" OR Answer$ = "yes"
> CLS
> PRINT "Thank you for your cooperation in the signing of our optional hit list, "; name$; "."
> PRINT "Please allow 24 to 36 hours for the processing of the hitman which we will send to your house."
> SLEEP 17
> CLS
> SCREEN 7
> CIRCLE (100, 100), 50, 14
> PSET (80, 80), 1
> PSET (120, 80), 1
> PSET (100, 100), 6
> LINE (75, 110)-(85, 125), 4
> LINE (85, 125)-(100, 130), 4
> LINE (100, 130)-(115, 125), 4
> LINE (115, 125)-(125, 110), 4
> SOUND 261.63, (1 * 5)
> SOUND 293.66, (1 * 5)
> SOUND 329.63, (1 * 5)
> SOUND 349.23, (1 * 15)
> SOUND 261.63, (1 * 5)
> SOUND 293.66, (1 * 5)
> SOUND 329.63, (1 * 5)
> SOUND 349.23, (1 * 20)
> SOUND 329.63, (1 * 5)
> SOUND 293.66, (1 * 5)
> SOUND 261.63, (1 * 15)
> SOUND 261.63, (1 * 10)
> SOUND 293.66, (1 * 10)
> SOUND 329.63, (1 * 10)
> SOUND 349.23, (1 * 10)
> PRINT "Thank you and have a wonderful day "; name$; "!!!"
>
> SUB ending
> price% = order% * amount%
> price2% = order2% * amount2%
> price3% = order3% * amount3%
> price4% = order4% * amount4%
> price5% = order5% * amount5%
> price6% = order6% * amount6%
> price7% = order7% * amount7%
> price8% = order8% * amount8%
> price9% = order9% * amount9%
> price10% = order10% * amount10%
> price11% = order11% * amount11%
> subtotal% = price% + price2% + price3% + price4% + price5% + price6% +
> price7% + price8% + price9% + price10% + price11% PRINT "total of this
> order "; price%
>
> PRINT "total of this order "; price2%
>
> PRINT "total of this order "; price3%
>
> PRINT "total of this order "; price4%
>
> PRINT "total of this order "; price5%
>
> PRINT "total of this order "; price6%
>
> PRINT "total of this order "; price7%
>
> PRINT "total of this order "; price8%
>
> PRINT "total of this order "; price9%
>
> PRINT "total of this order "; price10%
>
> PRINT "total of this order "; price11% PRINT PRINT "Your subtotal
> comes to:"
> PRINT subtotal%
> tax% = subtotal% * .0875
> PRINT "Your tax comes to:"
> PRINT tax%
> total% = subtotal% + tax%
> PRINT "Your total comes to:"
> PRINT total%
> PRINT "Press enter to continue"
> INPUT enter$
>
> END SUB
>
> SUB menu
> CLS
> PRINT "Please select from the menu below any thing you wish to order (type the PRICE into the blank)"
> PRINT "An externel Floppy drive 46.99$"
> PRINT "An external CD-ROM drive 72.55$"
> PRINT "An external DVD-ROM drive 99.99$"
> PRINT "An external CD/DVD-ROM combo burner drive 255.68$"
> PRINT "50 blank 80 minute CD-ROMs 25.32$"
> PRINT "50 blank 100 minute CD-ROMs 32.25$"
> PRINT "50 blank 100 minute DVDs 100.00$"
> PRINT "50 blank floppies 25.55$"
> PRINT "300 sheets of recycled computer paper 2.99$"
> PRINT "300 sheets of computer cardstock 4.99$"
> PRINT "300 sheets of bright computer paper 3.50$"
>
> END SUB
>
> My problem is that I cannot use my prices in my sub. I am really confused!!!!! I need to carry over my information. HELP?
>
> DECLARE SUB ending ()
> DECLARE SUB menu ()
>
> CLS
> PRINT "Please select from the menu below any thing you wish to order (type the PRICE of the item you wish to order)"
> PRINT "An externel Floppy drive 46.99$"
> PRINT "An external CD-ROM drive 72.55$"
> PRINT "An external DVD-ROM drive 99.99$"
> PRINT "An external CD/DVD-ROM combo burner drive 255.68$"
> PRINT "50 blank 80 minute CD-ROMs 25.32$"
> PRINT "50 blank 100 minute CD-ROMs 32.25$"
> PRINT "50 blank 100 minute DVDs 100.00$"
> PRINT "50 blank floppies 25.55$"
> PRINT "300 sheets of recycled computer paper 2.99$"
> PRINT "300 sheets of computer cardstock 4.99$"
> PRINT "300 sheets of bright computer paper 3.50$"
> INPUT order%
> CLS
> PRINT "How much would you like (do not spell out numbers)"
> INPUT amount%
> PRINT "Would you like to order anything else?"
> INPUT wouldyou$
> IF wouldyou$ = "y" OR wouldyou$ = "Y" OR wouldyou$ = "yes" THEN menu
> INPUT order2%
>
> CLS
> PRINT "How much would you like (do not spell out numbers)"
> INPUT amount2%
> PRINT "Would you like to order anything else?"
> INPUT wouldyou$
> IF wouldyou$ = "y" OR wouldyou$ = "Y" OR wouldyou$ = "yes" THEN menu
> INPUT order3%
>
> CLS
> PRINT "How much would you like (do not spell out numbers)"
> INPUT amount3%
> PRINT "Would you like to order anything else?"
> INPUT wouldyou$
> IF wouldyou$ = "y" OR wouldyou$ = "Y" OR wouldyou$ = "yes" THEN menu
> INPUT order4%
>
> CLS
> PRINT "How much would you like (do not spell out numbers)"
> INPUT amount4%
> PRINT "Would you like to order anything else?"
> INPUT wouldyou$
> IF wouldyou$ = "y" OR wouldyou$ = "Y" OR wouldyou$ = "yes" THEN menu
> INPUT order5%
>
> CLS
> PRINT "How much would you like (do not spell out numbers)"
> INPUT amount5%
> PRINT "Would you like to order anything else?"
> INPUT wouldyou$
> IF wouldyou$ = "y" OR wouldyou$ = "Y" OR wouldyou$ = "yes" THEN menu
> INPUT order6%
>
> CLS
> PRINT "How much would you like (do not spell out numbers)"
> INPUT amount6%
> PRINT "Would you like to order anything else?"
> INPUT wouldyou$
> IF wouldyou$ = "y" OR wouldyou$ = "Y" OR wouldyou$ = "yes" THEN menu
> INPUT order7%
>
> CLS
> PRINT "How much would you like (do not spell out numbers)"
> INPUT amount7%
> PRINT "Would you like to order anything else?"
> INPUT wouldyou$
> IF wouldyou$ = "y" OR wouldyou$ = "Y" OR wouldyou$ = "yes" THEN menu
> INPUT order8%
>
> CLS
> PRINT "How much would you like (do not spell out numbers)"
> INPUT amount8%
> PRINT "Would you like to order anything else?"
> INPUT wouldyou$
> IF wouldyou$ = "y" OR wouldyou$ = "Y" OR wouldyou$ = "yes" THEN menu
> INPUT order9%
>
> CLS
> PRINT "How much would you like (do not spell out numbers)"
> INPUT amount9%
> PRINT "Would you like to order anything else?"
> INPUT wouldyou$
> IF wouldyou$ = "y" OR wouldyou$ = "Y" OR wouldyou$ = "yes" THEN menu
> INPUT order10%
>
> CLS
> PRINT "How much would you like (do not spell out numbers)"
> INPUT amount10%
> PRINT "Would you like to order anything else?"
> INPUT wouldyou$
> IF wouldyou$ = "y" OR wouldyou$ = "Y" OR wouldyou$ = "yes" THEN menu
> INPUT order11%
>
> CLS
> PRINT "How much would you like (do not spell out numbers)"
> INPUT amount11%
> price% = order% * amount%
> price2% = order2% * amount2%
> price3% = order3% * amount3%
> price4% = order4% * amount4%
> price5% = order5% * amount5%
> price6% = order6% * amount6%
> price7% = order7% * amount7%
> price8% = order8% * amount8%
> price9% = order9% * amount9%
> price10% = order10% * amount10%
> price11% = order11% * amount11%
> subtotal% = price% + price2% + price3% + price4% + price5% + price6% +
> price7% + price8% + price9% + price10% + price11% PRINT "total of this
> order "; price%
>
> PRINT "total of this order "; price2%
>
> PRINT "total of this order "; price3%
>
> PRINT "total of this order "; price4%
>
> PRINT "total of this order "; price5%
>
> PRINT "total of this order "; price6%
>
> PRINT "total of this order "; price7%
>
> PRINT "total of this order "; price8%
>
> PRINT "total of this order "; price9%
>
> PRINT "total of this order "; price10%
>
> PRINT "total of this order "; price11% PRINT PRINT "Your subtotal
> comes to:"
> PRINT subtotal%
> tax% = subtotal% * .0875
> PRINT "Your tax comes to:"
> PRINT tax%
> total% = subtotal% + tax%
> PRINT "Your total comes to:"
> PRINT total%
> PRINT "Press enter to continue"
> INPUT enter$
>
> CLS
> PRINT "Hello my name is compu. I am the computerized version of our buisness. I take over after you have made your order."
> SLEEP 25
> CLS
> PRINT "What is your full first name"
> INPUT name$
> SLEEP 1
> DO
> CLS
> PRINT "Hello "; name$; "!!!"
> SLEEP 2
> CLS
> PRINT name$; "You must take a short survey in order to purchase this product so we may have your information on file to send the product to you. Do you wish to continue"
> INPUT survey$
> IF survey$ = "N" OR survey$ = "n" OR survey$ = "no" THEN END
> CLS
> SLEEP 2
> PRINT "What is your middle name"
> INPUT middle$
> CLS
> SLEEP 1
> PRINT "What is your last name"
> INPUT last$
> CLS
> SLEEP 1
> PRINT "What is your address"
> INPUT address$
> CLS
> SLEEP 1
> PRINT "What city do you live in"
> INPUT city$
> CLS
> SLEEP 1
> PRINT "What state do you live in"
> INPUT state$
> CLS
> SLEEP 1
> PRINT "What is your zipcode"
> INPUT zipcode
> CLS
> SLEEP 1
> PRINT "What is your current age in years"
> INPUT years%
> CLS
> SLEEP 1
> PRINT "We are now processing your entry. Your cooperation has been appriciated. Please be patient."
> SLEEP 6
> CLS
> PRINT "Please check your information below:"
> PRINT "Your full name is "; name$; " "; middle$; " "; last$
> PRINT "You live at "
> PRINT ; address$
> PRINT city$; ", "; state$; " "; zipcode
> months% = years% * 12
> days% = years% * 365
> PRINT "You are "; years%; " years old"
> PRINT "You are "; months%; " months old"
> PRINT "You are "; days%; " days old"
> PRINT "Is this correct? (Y or N)"
> INPUT Answer$
> LOOP UNTIL Answer$ = "Y" OR Answer$ = "y" OR Answer$ = "yes"
> CLS
> PRINT "Thank you for your cooperation in the signing of our optional hit list, "; name$; "."
> PRINT "Please allow 24 to 36 hours for the processing of the hitman which we will send to your house."
> SLEEP 17
> CLS
> SCREEN 7
> CIRCLE (100, 100), 50, 14
> PSET (80, 80), 1
> PSET (120, 80), 1
> PSET (100, 100), 6
> LINE (75, 110)-(85, 125), 4
> LINE (85, 125)-(100, 130), 4
> LINE (100, 130)-(115, 125), 4
> LINE (115, 125)-(125, 110), 4
> SOUND 261.63, (1 * 5)
> SOUND 293.66, (1 * 5)
> SOUND 329.63, (1 * 5)
> SOUND 349.23, (1 * 15)
> SOUND 261.63, (1 * 5)
> SOUND 293.66, (1 * 5)
> SOUND 329.63, (1 * 5)
> SOUND 349.23, (1 * 20)
> SOUND 329.63, (1 * 5)
> SOUND 293.66, (1 * 5)
> SOUND 261.63, (1 * 15)
> SOUND 261.63, (1 * 10)
> SOUND 293.66, (1 * 10)
> SOUND 329.63, (1 * 10)
> SOUND 349.23, (1 * 10)
> PRINT "Thank you and have a wonderful day "; name$; "!!!"
>
> SUB ending
> price% = order% * amount%
> price2% = order2% * amount2%
> price3% = order3% * amount3%
> price4% = order4% * amount4%
> price5% = order5% * amount5%
> price6% = order6% * amount6%
> price7% = order7% * amount7%
> price8% = order8% * amount8%
> price9% = order9% * amount9%
> price10% = order10% * amount10%
> price11% = order11% * amount11%
> subtotal% = price% + price2% + price3% + price4% + price5% + price6% +
> price7% + price8% + price9% + price10% + price11% PRINT "total of this
> order "; price%
>
> PRINT "total of this order "; price2%
>
> PRINT "total of this order "; price3%
>
> PRINT "total of this order "; price4%
>
> PRINT "total of this order "; price5%
>
> PRINT "total of this order "; price6%
>
> PRINT "total of this order "; price7%
>
> PRINT "total of this order "; price8%
>
> PRINT "total of this order "; price9%
>
> PRINT "total of this order "; price10%
>
> PRINT "total of this order "; price11% PRINT PRINT "Your subtotal
> comes to:"
> PRINT subtotal%
> tax% = subtotal% * .0875
> PRINT "Your tax comes to:"
> PRINT tax%
> total% = subtotal% + tax%
> PRINT "Your total comes to:"
> PRINT total%
> PRINT "Press enter to continue"
> INPUT enter$
>
> END SUB
>
> SUB menu
> CLS
> PRINT "Please select from the menu below any thing you wish to order (type the PRICE into the blank)"
> PRINT "An externel Floppy drive 46.99$"
> PRINT "An external CD-ROM drive 72.55$"
> PRINT "An external DVD-ROM drive 99.99$"
> PRINT "An external CD/DVD-ROM combo burner drive 255.68$"
> PRINT "50 blank 80 minute CD-ROMs 25.32$"
> PRINT "50 blank 100 minute CD-ROMs 32.25$"
> PRINT "50 blank 100 minute DVDs 100.00$"
> PRINT "50 blank floppies 25.55$"
> PRINT "300 sheets of recycled computer paper 2.99$"
> PRINT "300 sheets of computer cardstock 4.99$"
> PRINT "300 sheets of bright computer paper 3.50$"
>
> END SUB
>
> My problem is that I cannot use my prices in my sub. I am really confused!!!!! I need to carry over my information. HELP?