11-08-2024, 03:10 AM
(11-07-2024, 10:13 PM)madscijr Wrote:(11-07-2024, 10:08 PM)Kernelpanic Wrote: I don't really understand your problem description, but in general, local variables are preferable to global ones in every respect. In general, but sometimes one can't avoid it.Yeah, gosub is one of those hallmarks of spaghetti code that I completely avoid!
GoSub is one of those things... The QBasic/QuickBasic reference says that this is only supported for compatibility reasons, but it is not recommended.
I got the same aversion about GOTO. It's the sauce in spaghetti code "Once you use it hard to control where it goes, or gets used." I basically try to only use it as a way at the bottom of code to get to the top. I avoid for/next, in favor of do/loops. In a do/loop I can use loop exit, instead of another goto.