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 / Using multiple files

Author
Message
tiffit
9
Years of Service
User Offline
Joined: 1st Feb 2015
Location:
Posted: 2nd Feb 2015 03:01
So I like to be organized, and probably the best for me is using multiple files. So, how exactly would I do this? I want to call the player.agc file from the main.agc file, how would you do that?
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 2nd Feb 2015 10:43 Edited at: 2nd Feb 2015 10:43
After creating your project, you add new files by taking the

File | New File

option. You make this available to your project by including it in the main project, at the top:

#include "player.agc"

Any functions you write in player.agc are available from the main file, or any other files you include.

You can also #insert. This directly inserts whatever is in your file, into the place you used the #insert command.

Quidquid latine dictum sit, altum sonatur
tiffit
9
Years of Service
User Offline
Joined: 1st Feb 2015
Location:
Posted: 3rd Feb 2015 03:12
What am I doing wrong?

My main.agc:


My player.agc

I just did this to test if it would work, and it didn't, dead did not equal to 1
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 3rd Feb 2015 09:08 Edited at: 3rd Feb 2015 09:09
You need to create a function or sub-routine in the player.agc file that you call from the first file. Not sure what you are trying to do here but having multiple do-loop's can cause all sorts of problems.

Here is a simple example of what an additional file is good for.

main.agc:


player.agc:



Using AppGameKit V2 Tier 1
tiffit
9
Years of Service
User Offline
Joined: 1st Feb 2015
Location:
Posted: 4th Feb 2015 00:38
OH ok, thanks, now it works!
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 4th Feb 2015 06:58
One of the other problems was including main.agc in player.agc.

Don't include main.agc in anything else. It is the main file that gets executed.

When the code files are compiled, all are processed (if included in either main.agc or in a file that is included in main.agc). This makes all the globals and functions available to all other files.

Cheers,
Ancient Lady
tiffit
9
Years of Service
User Offline
Joined: 1st Feb 2015
Location:
Posted: 5th Mar 2015 06:54
ok, so how do I use a variable from one file on a different file?
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 5th Mar 2015 15:28
You make your variables global. This isn't about files, but about use of variables in functions.

Global MyVariable as Integer

Quidquid latine dictum sit, altum sonatur

Login to post a reply

Server time is: 2024-04-16 15:33:08
Your offset time is: 2024-04-16 15:33:08