Page 1 of 1

RETURN without GOSUB

Posted: Thu Aug 06, 2015 4:46 pm
by the_wesley_watkins
I am creating a program with multiple libraries and I keep getting this error. It would be too long to post a peice of the code for my program, so I wrote a little sample program that basically does the same thing:

Code: Select all

b = 5
a = 3

IF b > a THEN
	GOSUB bwins
ELSE
	IF a > b THEN
		GOSUB bloses
	END IF
END IF 

bwins:

{Test2.txt}

RETURN


bloses:

{Test3.txt}

RETURN
TEST2.txt just says to print "winner" and TEST3.txt just says to print "loser"

Re: RETURN without GOSUB

Posted: Thu Aug 06, 2015 7:16 pm
by rbytes
When your code executes, it checks your IF-THEN statements and performs whichever GOSUB is indicated. But then it continues, runs past the END IF and the first label, and encounters a RETURN with no GOSUB. I fixed the code just by putting an END statement after the END IF. A GOTO would also work - anything that stops the execution from getting to your GOSUB routines without a GOSUB.