Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / [SOLVED] OMG I encountered a RETURN statement!

Author
Message
basicFanatic
6
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 19th Sep 2018 16:27 Edited at: 19th Sep 2018 16:28
After my game has run, this error message pops up:
Quote: "Encountered a RETURN statement when not in a GOSUB in _init.agc at line 11"


I have this in main.agc:
#include "_init.agc"
gosub _init


I have this in _init.agc:
_init:
SetWindowTitle( "2D Dynamic Shaddows" )
SetWindowSize( 160, 100, 1 )
SetVSync( 1 )
SetResolutionMode( 1 )
SetVirtualResolution( GetMaxDeviceWidth(), GetMaxDeviceHeight() )
SetDefaultMagFilter(0) // 0 nearest 1 liniar
SetDefaultMinFilter(0)
SetScissor( 0, 0, 0, 0 )
SetPrintSize( 32 )
return

Does this make sense?

The author of this post has marked a post as an answer.

Go to answer

Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 19th Sep 2018 16:59 Edited at: 19th Sep 2018 17:00
This post has been marked by the post author as the answer.
If you dont actually call END then yes it makes sense as your program breaks out of its game loop and starts running through the rest of the code.

In fact in the documentation for #include it states

Quote: "Be aware that included source code is appended to the end of the program, so if you include any code that isn't part of a function it will be run if your main program reaches the end of its source code. "


And why is this not a function!! (lol) gosubs and returns... tut tut (only joking if I didnt say it then someone else would have )
basicFanatic
6
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 19th Sep 2018 18:26
"end", yes of course!

Long live GOTO! Those "functions" are just a fad.

Seriously, I use gosub strictly for crudely move bits of code away from main.agc Mentally, using another concept than a function lets me know that the purpose is radically different from that of a function. When I see a gosub in main.agc, I know that it simply means "here's a bit of code". I also know that the gosub is only executed once, and I know that it has no input or return statements.


Riusz
8
Years of Service
User Offline
Joined: 27th Feb 2016
Location:
Posted: 20th Sep 2018 09:46
Have you try with #insert instead of #include ?

Riusz
basicFanatic
6
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 20th Sep 2018 14:44
Yes, but I actually think I prefer #include! The #insert command inserts everything in the file right there, and I want the files functions to be placed neatly at the end of main.agc
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 20th Sep 2018 23:04
@basicFanatic:
I do something very similar. Each of my included files are laid out like this.


Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 22nd Sep 2018 16:21
Almost exactly what mine look like also Prof, though i have a list of functions and descriptions at the top for quick reference
http://games.joshkirklin.com/sulium

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.

Login to post a reply

Server time is: 2024-03-29 02:31:49
Your offset time is: 2024-03-29 02:31:49