Except meby Mac
This works just fine:
CLS: CALL a: CALL b: SYSTEM
SUB a: Num = 1: GOSUB x: EXIT SUB
x: PRINT "Got Here"; Num: RETURN
SUB b: Num = 2: GOSUB y: EXIT SUB
y: PRINT "Got Here"; Num: RETURN
It shows that SUBs keep the two versions of "Num" distinct, as you would expect.
HOWEVER, if you rename "y" to "x" in SUB b, you get
SUB b: Num = 2: GOSUB x: EXIT SUB
x: PRINT "Got Here"; Num: RETURN <--- Duplicate Label
And if you remove that line, hoping to use the "other" label, you get
SUB b: Num = 2: GOSUB x: EXIT SUB <---Label Not Defined
So there is a bug in QBasic whereby labels are not kept distinct for GOSUB/GOTO.
I love GOSUB's! They help reduce the need for indentation and help keep if/then/else constructions small, etc. But now I see a problem. I should be able to keep a library of SUBs and FUNCTIONs and grab any at random and put them in a program I am writing. Now I have to beware of duplicate GOTO labels. Rats!!
So in this Kriegspiel Referee project, each design module should have had, as part of its specification, a rule such as
# Start all internal GOTO/GOSUB labels (if any) with "x"
where "x" is unique for each design module.
We were simply lucky that we encountered no integration errors.
from IP address 220.127.116.11
Return to Index
|Response Title||Author and Date|
|Yes, I noticed that too...||TheBOB on Sep 5|
|*I've always just used "SubnameLabel:" and "MainLabel:"||The PhyloGenesis on Sep 5|
|Not a bad idea||Mac on Sep 5|
|* I did not know that you did not know that but I know that you know that now.||Pete on Sep 5|
|* But at my age I might not know that tomorrow||Mac on Sep 5|