Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How does one access a created sub?
#1
I've never really used subs before, so now I'm confused as to accessing my sub. I have a sub DoMainMenu, but when I use the command GOSUB DoMainMenu, I get a "Label not defined" error. What am I doing wrong?
33l t3h wr47h 0f t3h 0m3g4...and stuff.
Reply
#2
Sorry about that...I figured out how to do that...but I do have another question. Are line labels in the sub shared with the main program the same way variables are? I'm going to try this now...
33l t3h wr47h 0f t3h 0m3g4...and stuff.
Reply
#3
Nope. Labels are only visible from within the bounds of the SUB where they belong.

There is one exception: You can have DATA after a label (only in the main section, not inside a sub) and you can RESTORE to that label from wherever.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#4
They're not shared, but the namespace is shared. You can't have duplicate labels in the program. IMHO, that is very unfortunate.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#5
That's not unfortunate. That's just BASIC.
img]http://usuarios.vtr.net/~disaster/sigs/annoyizer.php[/img]
Reply
#6
Just BASIC? In C, C++, etc., all variables/labels are completely within their scope - i.e. you can have duplicates there too, I think.
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#7
Having separate label namespaces wouldn't kill anyone.

Powerbasic has this capability.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#8
Nah, in PB you have the same restriction. With C happens the same, I believe.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#9
Aga, arent you the only one here who uses gotos and labels? Not unfortunate for us :wink: j/k
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)