END from within GOSUB

All aspects of programming on the Commander X16.
Post Reply
User avatar
ahenry3068
Posts: 1195
Joined: Tue Apr 04, 2023 9:57 pm

END from within GOSUB

Post by ahenry3068 »

Is it safe to END a program after a GOSUB without a RETURN. It occurred to me since BASIC is the "OS" this could cause problems with subsequent programs. ?

Most of my BASIC experience is compiled basic on x86 and this was never a problem there.
TomXP411
Posts: 1806
Joined: Tue May 19, 2020 8:49 pm

Re: END from within GOSUB

Post by TomXP411 »

Yes, END within a GOSUB is fine. The RUN command does an implied NEW, which resets variables, the FOR loop registers, and the stack.
User avatar
ahenry3068
Posts: 1195
Joined: Tue Apr 04, 2023 9:57 pm

Re: END from within GOSUB

Post by ahenry3068 »

I'm happy for the answer. Thank You. I suspected is was OK but I've had some weird memory management errors come up
when programming in C & Pascal on 16 bit MS-DOS and Windows in the past....

Again, thanks for the answer.
User avatar
ahenry3068
Posts: 1195
Joined: Tue Apr 04, 2023 9:57 pm

Re: END from within GOSUB

Post by ahenry3068 »

I want a universal quit Key for a Craps game I'm working on. Easier to do a GOSUB after input no matter
where you are in the game. Then I just need to RETURN if the user doesn't want to quit.
Post Reply