RETURN without GOSUB

Post Reply
the_wesley_watkins
Posts: 42
Joined: Wed Jul 29, 2015 3:53 pm
My devices: Ipad
Iphone

RETURN without GOSUB

Post 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"

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: RETURN without GOSUB

Post 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.
The only thing that gets me down is gravity...

Post Reply