11-12-2022, 04:24 AM
If you're more comfortable writing subprograms then don't change that. Using "GOSUB" and "RETURN" isn't a great advantage by this time especially if you expect your BASIC code compatible with Freebasic or Purebasic. For example, for Freebasic you only need to change function name on LHS and equals to "RETURN", that's why "GOSUB" was eventually dumped by them to follow along with Visual Basic.
Coding while relying on "GOSUB" sections of code must have global variables always. If you're not used to it, it's going to be a mess trying to force that issue with "SUB... END SUB" and "FUNCTION... END FUNCTION" while they weren't designed for that purpose. If you need a local variable that has to keep its value after the subprogram is in must leave, and then come back, use "STATIC" to declare it instead of "DIM". In fact the whole subprogram could be declared "STATIC" (use keyword at the end after parameter list). But probably you knew this already.
Coding while relying on "GOSUB" sections of code must have global variables always. If you're not used to it, it's going to be a mess trying to force that issue with "SUB... END SUB" and "FUNCTION... END FUNCTION" while they weren't designed for that purpose. If you need a local variable that has to keep its value after the subprogram is in must leave, and then come back, use "STATIC" to declare it instead of "DIM". In fact the whole subprogram could be declared "STATIC" (use keyword at the end after parameter list). But probably you knew this already.