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 / Keeping it Simple - The #include directive

Author
Message
TinTin
20
Years of Service
User Offline
Joined: 16th May 2006
Location: BORG Drone Ship - Being Assimilated near Roda Beta (28)
Posted: 13th Apr 2007 11:21 Edited at: 13th Apr 2007 12:25
I was working on a large project in VBP and I realised that it was getting out of control, unmanageable and needed split up into smaller modules.

I now have my code split up into smaller more manageable units (Setup.dba, Loader.dba, Main.dba etc...) with Main.dba being the entry point. I've used the #include to link the other files on a first level basis from the Main.dba. I now intend using the #include in the lower level files (Setup.dba, Loader.dba) to link to other smaller function files. This can lead to multiple includes of the same file into a project, I know that C++ uses the (#ifndef, #define, #endif) commands to block multiple declarations.

Q1. is there support for these commands (or similar) in DBP ?


Q2. is there a way of passing a variable BYREF into a function? (see bellow)

the above code should print 10,
the above code is very simple, I don't want to return a value EndFunction rVal as the function will be adjusting several non global variables.

adding the * didn't work...

Cyberspace was becoming overcrowded and slummy so I decided to move. These nice chaps gave me a lift.
Milkman
20
Years of Service
User Offline
Joined: 30th Nov 2005
Location: United States
Posted: 13th Apr 2007 11:39
There is not native support for #ifdef and the like, but two people on the forums have implemented c-style preprocessors for dbp. One is dbpre and can be found here:

http://forum.thegamecreators.com/?m=forum_view&t=89899&b=5

And the other is by DSG, and can be found here:

http://forum.thegamecreators.com/?m=forum_view&t=103402&b=8

Hope that helps.

Who needs a signature?
Scraggle
Moderator
22
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 13th Apr 2007 11:40
No, there isn't.

What I would suggest is to get rid of all instances of the #include command and instead use the IDE to include your sub-code. That way you will only ever have one copy of each part of your code.



TinTin
20
Years of Service
User Offline
Joined: 16th May 2006
Location: BORG Drone Ship - Being Assimilated near Roda Beta (28)
Posted: 13th Apr 2007 12:47
Thanks MilkMan that pre-processor looks good.

@Scraggle - that is only useful for small projects, if I have modules that call modules that call modules then that method would require checking the modules to see what they require to be included (in a small project that'd be fine) in bigger projects it's not.

Cyberspace was becoming overcrowded and slummy so I decided to move. These nice chaps gave me a lift.
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 13th Apr 2007 13:27
DBPro doesn't mind you including the same file more than once

Login to post a reply

Server time is: 2026-06-26 12:17:09
Your offset time is: 2026-06-26 12:17:09