Posted: 1st Oct 2011 12:03
I just moved some of my functions to a new source file (Initialise.agc). Now, I can Run (Ctrl-F5) the game, but I can't Compile (F4, Ctrl-F4 or F5) the game, because it cannot find the Init() routine in the new file.

As you can see in the screenshot, the new file is part of the project, and Running works, so what have I done wrong?

Posted: 1st Oct 2011 12:22
Use

+ Code Snippet
#INCLUDE "Initialise.agc"


at the top of your code then it'll work again
Posted: 1st Oct 2011 12:37
I found errors with the #include command, see the google issue board, issue #83
Posted: 1st Oct 2011 12:51
The "problem" is that included files get appended at the end of the final source code. So your Globals etc. get dimed at the end. Have you tried to put your Dim and LoadImage code into a sub?

+ Code Snippet
#INCLUDE "yourfile.agc"

Gosub InitData


-> in yourfile.agc

InitData:

Global foo as Integer
Global bar as Integer
foo = LoadImage("yourimage.png")
etc.

Return


Maybe that'll work
Posted: 1st Oct 2011 14:02
Thanks Hubdule ! You fixed my issue

I now just gosub the content of the include files just after the #include command, and now it gets declared at the start of the program.

I think the #include command, should insert source files infront of the main, not after... makes more sense.
Posted: 1st Oct 2011 14:45
No problem. I think it's just easier to implement something like

-> Main file
-> Append include file
-> Append include file

then

-> Main file -> search for right position
-> merge all includes there
-> then add the rest of the main file

But it's nice to know now that it works like that.
Posted: 1st Oct 2011 17:16
I was wondering why it was behaving strangly. Now that you have mentioned that includes get appended and not inserted, it makes sence. Weird but it is workable.