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 / How can I sort type definitions into multiple agc files? (#include/#insert/#etc)

Author
Message
Greenwich
9
Years of Service
User Offline
Joined: 10th Dec 2014
Location:
Posted: 15th Feb 2015 22:45
Hi everybody. I'm having some sort of dependencies problem.

I'm trying to figure out how I can define types in one agc file, and then reference those types from a different agc file, when neither of these are the main.agc file.

Here's a heavily simplified example, which shows what I'm trying to do:

main.agc


types.agc


gridstuff.agc


I've tried both #include and #insert, and I've tried moving the definition of DepthOf to the other agc files (although even if it worked that's a problem conceptually).

Basically I can't seem to get main.agc to understand that the grid creation and manipulation functions (in gridstuff.agc) are using types that have been defined (in types.agc).

It's mean time. *averages*
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 16th Feb 2015 00:45
Your 'blah blah' excertp for gridstuff.agc looks like you don't have the 'endfunction' statement for PrepGridTiles. It may just have disappeared when you did the 'blah blah'. But, if it is actually missing, that is what may be causing the problem.

Cheers,
Ancient Lady
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 16th Feb 2015 12:06
DepthOf as DepthSet

should be

Global DepthOf as DepthSet

The way you've written it, types.agc needs to be an #insert, not a #include.
If you use #include, all of your code (but not type definitions and declarations) needs to be in functions.

Quidquid latine dictum sit, altum sonatur
Greenwich
9
Years of Service
User Offline
Joined: 10th Dec 2014
Location:
Posted: 17th Feb 2015 21:03 Edited at: 17th Feb 2015 21:45
Global! I remember being told not to overuse global variables, back in high school programming or something, so I probably overcompensate and forget to use them even when they're warranted. This is really a perfect example of when to use a global variable.

Anyway, I tried it and it works perfectly. Thanks!

It's mean time. *averages*
paulrobson
9
Years of Service
User Offline
Joined: 22nd Nov 2014
Location: Norfolk, England
Posted: 17th Feb 2015 23:47
Globals are fine - you just minimise them. You have to have them in some way shape or form.

What you should avoid - sounds like you are doing - is having them all over the place - group data together in types. I tend to have seperate types and the functions that work on those types all in seperate files.

Login to post a reply

Server time is: 2024-11-21 15:51:02
Your offset time is: 2024-11-21 15:51:02