![]() |
Can I use labels in SUBs - 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: Can I use labels in SUBs (/thread-10307.html) |
Can I use labels in SUBs - jhesski - 06-04-2020 I have recently returned to Qbasic after many years. I never used SUBs before but I am attempting to learn and use them as I think they will make the code cleaner. I moved some code from the main code to a SUB and it appears labels or line numbers are not allowed in a SUB? I looked in the help and I don't see any place in the documentation that says this will not work. Can someone explain if I need to do something different or why this would not work? Code: SUB init I get an error of "Label not defined" when I try to run the code. Thank you for your help. RE: Can I use labels in SUBs - jofers_ - 08-11-2020 You appear to have stumbled on a not-well-documented limitation of QBASIC: the ON...GOTO/GOSUB commands must refer to a module-level label or line number PDS 7.1 has ON LOCAL ERROR to allow this for ON ERROR, but not for the other commands. |