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.

DarkBASIC Professional Discussion / Handle #Include the way it's meant to be handled!

Author
Message
MikeK
21
Years of Service
User Offline
Joined: 13th Sep 2004
Location: Apparently
Posted: 17th May 2010 20:01
Can we please have it so that when you use #include, it will include the contents of the specified file at the location of the command?

It will prevent having dozens of variables having to be defined at the head of the main source code, when they could be defined in the relevant include source.

DBPro must be the only compiler in the world to not follow that rule.

:: HybridTwo Sound & Music Production Studio : BinaryZoo Studios ::
revenant chaos
DBPro Master
19
Years of Service
User Offline
Joined: 21st Mar 2007
Location: Robbinsdale, MN
Posted: 17th May 2010 21:40
I am pretty sure that the IDE handles all of the the including.
MikeK
21
Years of Service
User Offline
Joined: 13th Sep 2004
Location: Apparently
Posted: 17th May 2010 21:55
Yeah, by appending the contents of such included files at the end of the main file.

If you have an include file that requires definition of Globals, or Constants, then it would fail, if you need to access those definitions in the main body of the program.

:: HybridTwo Sound & Music Production Studio : BinaryZoo Studios ::
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 17th May 2010 22:08
Quote: "If you have an include file that requires definition of Globals, or Constants, then it would fail, if you need to access those definitions in the main body of the program."

I don't think that's true, I declare globals in my included dba's all the time. In fact I almost always have a seperate dba for "setup"... I don't know about constants though

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 18th May 2010 13:40
Yeah, I tend to have a subroutine for initiating variables, then just call that from the main sources. Subroutines work in includes - I'm not sure that they did before, but it works now and is really quite neat to work like that. Personally I like to have separate IDE's for each source file, instead of using the built in 'include' features. I mostly use the old IDE though, things might be better in the new one.


Health, Ammo, and bacon and eggs!
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 18th May 2010 15:47
Include file added via the IDE get appended at the end of the main source. #Included files get added at the point of inclusion by the compiler.

My signature is NOT a moderator plaything! Stop changing it!
tiresius
23
Years of Service
User Offline
Joined: 13th Nov 2002
Location: MA USA
Posted: 18th May 2010 16:04
Quote: "Include file added via the IDE get appended at the end of the main source. #Included files get added at the point of inclusion by the compiler."

Have you verified that with a source code example? I thought that too but IanM debunked my assumption and said #include just appends to the end of the main source. I didn't try it out to confirm because I never use #include anyway, but I assume IanM was right because he always is.

@MikeK
As mentioned before you should setup a gosub routine to declare global variables, etc. and just call it from your main source. Nothing wrong with doing that, in my opinion, and it's actually neater than assuming execution should run all the way through a #include file.

Something tells me you're not using functions at all in these included files?


A 3D marble platformer using Newton physics.
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 18th May 2010 23:24
However you include additional code files, the code is always appended to the end of the source code.

You can test this yourself by putting a single print statements into code files like so:

main.dba


other.dba


If you get main.dba printed, then the file was appended. If you get other.dba printed, then file file was inserted.

Quote: "Can we please have it so that when you use #include, it will include the contents of the specified file at the location of the command?"

Probably won't happen, mainly for compatibility reasons and because of the line-number issues.

Login to post a reply

Server time is: 2026-06-26 23:38:14
Your offset time is: 2026-06-26 23:38:14