Qbasicnews.com
November 12, 2019, 05:51:33 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Gosub not working correctly  (Read 3874 times)
Tia
Member
*
Posts: 37


« on: March 02, 2008, 03:56:36 AM »

unless I have really screwed up this specific code (not part of the competition) gosubs I am using in a program am not working correctly.  I do not believe I have used them wrong please correct me if I have.

Code:
'/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
'/\                        Creating all of the gosubs                        /
'/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/                                                                          /

CLS
GOSUB A100.Initialize
GOSUB B100.CreateMenu
'GOSUB C100.WrapUp

'/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
'/\                              Initialize                                  /
'/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

A100.Initialize:
RandomMoney = 0
Name$ = ""
Hours = 0
AmountEarned = 0
RETURN

'/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
'/\                             Create Menu                                  /
'/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

B100.CreateMenu:
        LOCATE 2, 25: PRINT "Freelancers"
        LOCATE 4, 25: PRINT "Code"
        LOCATE 4, 33: PRINT "Function"
        LOCATE 5, 25: PRINT "----"
        LOCATE 5, 33: PRINT "--------"
        LOCATE 6, 27: PRINT "1"
        LOCATE 7, 35: PRINT "2"
        LOCATE 6, 33: PRINT "Run Program"
        LOCATE 7, 33: PRINT "Exit Program"
RETURN


Logged
Mac
Senior Member
**
Posts: 243


WWW
« Reply #1 on: March 02, 2008, 06:20:41 AM »

CLS
GOSUB A100.Initialize
GOSUB B100.CreateMenu
'GOSUB C100.WrapUp

'/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
'/\                              Initialize                                  /
'/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

A100.Initialize:
RandomMoney = 0
Name$ = ""
Hours = 0
AmountEarned = 0
RETURN

There is a need to terminate your main program after
'GOSUB C100.WrapUp
otherwise, the code will continue into A100.Initalize AGAIN!

And since you entered "A100.Initalize" without a GOSUB,  it
will bomb out when it reaches RETURN. Nowhere to return to.

So code

CLS
GOSUB A100.Initialize
GOSUB B100.CreateMenu
'GOSUB C100.WrapUp
END

See the END? You must have that.
Logged
Tia
Member
*
Posts: 37


« Reply #2 on: March 02, 2008, 02:55:39 PM »

Ok thats what I thought at first.  Man not using QBasic for awhile really is making a impact on my ability to do it lol.
Logged
Tia
Member
*
Posts: 37


« Reply #3 on: March 02, 2008, 05:56:11 PM »

I am having trouble making it a .exe it says it can't find a library.  I am not sure what to enter when it says new file spec.  Can anyone help me.
Logged
Mac
Senior Member
**
Posts: 243


WWW
« Reply #4 on: March 02, 2008, 10:49:12 PM »

I am having trouble making it a .exe it says it can't find a library.  I am not sure what to enter when it says new file spec.  Can anyone help me.

Assuming your program is z.bas, try starting QB like this

qb z.bas /L

Mac
Logged
LPG
Member
*
Posts: 61

semper ubi sub ubi (always wear under wear)


« Reply #5 on: April 19, 2008, 12:47:21 AM »

You can enter the path of the file it asks for e.g c:\qbasic\bc.exe
Logged

WHILE RPG$ <> "complete" : make up silly excuses :WEND
zoasterboy
Guru
**
Posts: 295


Personal Text!


WWW
« Reply #6 on: April 22, 2008, 02:07:10 PM »

Quote
You can enter the path of the file it asks for e.g c:\qbasic\bc.exe

I usually do this by copying the Qbasic directory's contents into the C drive, and when it asks for the path I just enter : "C:\"

Makes it a little less time consuming I suppose.
Logged

-yah
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!