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 / Functions in #include files

Author
Message
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 14th Nov 2011 01:13
What's the point?
You have to declare the #include "myfuncs.agc" at the top of your main source (why?) else you get errors referencing the functions within. No matter that the function was at the bottom of your main source file - if you #include it there, it doesn't get recognised.

Of course, then any compile error after that is offset by the amount of lines in your include file, so you may as well not bother as line xxx isn't the actual error, it's line xxx-(lines in include file)

Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 14th Nov 2011 06:32
all includes get appended at the bottom of the source file!

If you want something earlier so use an gosub that can even be used before the include command.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 14th Nov 2011 08:02
Quote: "What's the point?
You have to declare the #include "myfuncs.agc" at the top of your main source (why?) else you get errors referencing the functions within. No matter that the function was at the bottom of your main source file - if you #include it there, it doesn't get recognised."

Seems pretty logical to me, using include at the top makes it easier to check if you've missed something.

Quote: "Of course, then any compile error after that is offset by the amount of lines in your include file, so you may as well not bother as line xxx isn't the actual error, it's line xxx-(lines in include file)"

The compiler does tell you which file the error is in as well, you'll get used to it. It's pretty easy once you understand it.

MobileCreator
12
Years of Service
User Offline
Joined: 1st Jun 2011
Location: Ottawa - Canada
Posted: 14th Nov 2011 13:35
Hi,

calling a function that it is inside a second source file can be done everywhere throughout main.agc, as long as you use the include at the top of main.agc.

Not sure if I followed what kind of errors you're getting... Maybe if you show a example?

Cheers

----------
Paulo
http://www.mobilecreators.com
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 15th Nov 2011 00:42
@baxslash:
Not much use when I get "error at line 2100" and I have to subtract the amount of lines in myfuncs.agc (maybe some other files too)
It's not actually at line 2100 because of the concatenation.

@Cliff:
If the includes get appended at the bottom of the main source file, then why can't I #include them there then?

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 15th Nov 2011 09:24 Edited at: 15th Nov 2011 09:25
Quote: "Not much use when I get "error at line 2100" and I have to subtract the amount of lines in myfuncs.agc (maybe some other files too)
It's not actually at line 2100 because of the concatenation."

That's odd, mine tells me the right line number and which included file it's in... I'll send a screenshot:


Attachments

Login to view attachments
MobileCreator
12
Years of Service
User Offline
Joined: 1st Jun 2011
Location: Ottawa - Canada
Posted: 15th Nov 2011 19:14
Hi nz0,

now I've got what you mean. I can tell you that the line number is still a mystery to me. Sometimes I get the error at the right line, sometimes, it is completely off. I'll pay more attention to that and see if I can see a pattern. But I agree, this needs improvement.

Cheers

----------
Paulo
http://www.mobilecreators.com

Login to post a reply

Server time is: 2024-03-29 14:41:28
Your offset time is: 2024-03-29 14:41:28