Posts: 2
Threads: 1
Joined: Jan 2004
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.
Posts: 2
Threads: 1
Joined: Jan 2004
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.
Posts: 6,419
Threads: 74
Joined: Mar 2002
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.
Posts: 3,368
Threads: 195
Joined: Jan 2003
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.
Posts: 749
Threads: 4
Joined: Jun 2002
That's not unfortunate. That's just BASIC.
img]http://usuarios.vtr.net/~disaster/sigs/annoyizer.php[/img]
Posts: 3,616
Threads: 287
Joined: Jan 2003
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.
Posts: 3,368
Threads: 195
Joined: Jan 2003
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.
Posts: 6,419
Threads: 74
Joined: Mar 2002
Nah, in PB you have the same restriction. With C happens the same, I believe.
Posts: 2,771
Threads: 96
Joined: Oct 2003
Aga, arent you the only one here who uses gotos and labels? Not unfortunate for us :wink: j/k