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.

AppGameKit Classic Chat / How do I add another .agc file to run together with my code?

Author
Message
Midget Blaster
AGK Developer
7
Years of Service
User Offline
Joined: 7th May 2016
Location:
Posted: 1st Oct 2016 10:50
Hey, I've been trying for a while, but how do I add another .agc file to organise my code better? When I try to add one, it either isn't connected to my project or doesn't run together.
Harlequin
14
Years of Service
User Offline
Joined: 22nd Mar 2010
Location: Melbourne (AU)
Posted: 1st Oct 2016 11:30
Hi MB,

you use
#include "my_external_file.agc"

Typically you place these "includes" at the top of your file so they are all in one place.

cheers
It\'s late, I\'m tired, out of coffee and now I\'m wet.
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 1st Oct 2016 13:25
#include will append the file to the end of your source, #insert will insert it exactly where your #insert command is within your source.
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
JLMoondog
Moderator
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 2nd Oct 2016 09:27
The way I organize my source files..
1) I use #include for my functions.agc file, this places all my functions at the end of my code in main.agc where they belong.
2) I use #insert for the rest of my name.agc files, regardless of what they are for.
3) I stick all my #include/insert commands at the top of my source file, before any other command, this allows me to use unique app and screen/resolution data load / apply functions.

Properly organized code makes for a happy programmer.
Midget Blaster
AGK Developer
7
Years of Service
User Offline
Joined: 7th May 2016
Location:
Posted: 2nd Oct 2016 10:20
So if I have a function in one file and call it in the other, It would work fine? When do I use #include and when do I use #insert? And one more thing. How do I add a file to my current project? Thanks guys for your help!
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 2nd Oct 2016 14:08
Quote: "And one more thing. How do I add a file to my current project
"


Open File. Then when it appears in the project window, right-click and add to current project.

Quote: "When do I use #include and when do I use #insert?"


If you would write the code at the end of the existing code (e.g a function) then #include it and it will be appended to the end.
If you want it right where you declare it (e.g a list of constants at the top of your program), then #insert it.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 3rd Oct 2016 09:05
I've never used #insert, so I guess it's all programmers choice.

Login to post a reply

Server time is: 2024-04-26 11:33:55
Your offset time is: 2024-04-26 11:33:55