Qbasicnews.com
Gosub not working correctly - Printable Version

+- Qbasicnews.com (http://qbasicnews.com/newforum)
+-- Forum: QBasic (http://qbasicnews.com/newforum/forum-4.html)
+--- Forum: QB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-11.html)
+--- Thread: Gosub not working correctly (/thread-10090.html)



Gosub not working correctly - Tia - 03-02-2008

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





Re: Gosub not working correctly - Mac - 03-02-2008

(03-02-2008, 11:56 AM)Tia link Wrote: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.


Re: Gosub not working correctly - Tia - 03-02-2008

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.


Re: Gosub not working correctly - Tia - 03-03-2008

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.


Re: Gosub not working correctly - Mac - 03-03-2008

(03-03-2008, 01:56 AM)Tia link Wrote: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


Re: Gosub not working correctly - LPG - 04-19-2008

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


Re: Gosub not working correctly - zoasterboy - 04-22-2008

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.