Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Gosub not working correctly
#1
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


Reply
#2
(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.
Reply
#3
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.
Reply
#4
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.
Reply
#5
(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
Reply
#6
You can enter the path of the file it asks for e.g c:\qbasic\bc.exe
WHILE RPG$ <> "complete" : make up silly excuses :WEND
Reply
#7
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.
-yah
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)