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 / Including Source Files

Author
Message
Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 3rd Jul 2003 18:27
I'm having some problems including source files, and not entirely sure what I should be doing. I've made modules in C and Pascal before, so I'm experience with them, but not with db. I dont seem to have any help on them in my help files, so I must be missing some technical docs.

My questions are:
(1) In C and Pascal you have to make include file headers with things like IMPLEMENTATION followed by the names of the functions below. Do you need anything like that in db, or do you literally just have a load of functions in a source file and just include it?

(2) Arrays are automatically global in db, so if I define an array outside of a function, I dont have to pass it to that function as a parameter - it's just global. However, it seems that this isn't the case with an include file. So if I define an array in my main source and then try and access it in my include file, it doesnt recognise it. Is this correct? It also seems you cant pass arrays as parameters, which obviously makes what I'm trying to do impossible.

(3) Whats the exact process I need to follow?

Any help would be appreciated. I know I could just copy and paste all the source into one big source file, but when we hit 10000+ lines of code, its going to get very messy. Also, our group are working via the internet, so ideally we'll be incorporating our individual work together as #included source files to make it much easier to organise it.

Cheers.
Machine: P4 2200, 1GB RAM, GeForce4 64MB, Audigy Platinum
http://www.breakbeat-terrorism.co.uk
(It's not all about the coding)
MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 3rd Jul 2003 19:02
1) You can either use the #include statement or add files to the project area.

2) Try putting the GLOBAL command before the array defined in the included file. I dont know about #include, but it should be accessable if you include the file in the project area.

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins and other exciting things - oh my, yes!
APEXnow
Retired Moderator
23
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 3rd Jul 2003 19:35
I've also found that in DarkBASIC Professional, it is best to add the included files to the project using the Files viewer of your project rather than use the #include directive. I had problems compiling and running functions when they were included using the #include statement, probably due to the fact that it was being included twice or something.

Either way, don't use #include in DBPro, just add the new files to your project using the project file viewer window.

MSI/AMD Athlon 1300, 256Mb, 60GbHD, SoundBlaster Live!, GeForce 4 MX440-64Mb, Win2K, DX9, DarkBASIC Pro(PUv4.1)
Mnemonix
23
Years of Service
User Offline
Joined: 2nd Dec 2002
Location: Skaro
Posted: 3rd Jul 2003 19:41
#include has never worked for me in darkbasicpro. You just add the multiple sources to the project folder. They are automatically included

"We are getting aggravated"
"Yes, we are"
Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 3rd Jul 2003 19:44
I was including the file and using #include. I've managed to mess up everything I was doing before, but I tested something quickly without using #include and it seems it might do the job. I'll give that a go, cheers.

Machine: P4 2200, 1GB RAM, GeForce4 64MB, Audigy Platinum
http://www.breakbeat-terrorism.co.uk
(It's not all about the coding)
Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 3rd Jul 2003 20:03
Ok, it appears to work when I stick "GLOBAL" in front of all my array definitions, but I also cant have type definitions in the include file. They have to be copied to the main source, but thats ok.

Still testing, but it looks like all is good.

Machine: P4 2200, 1GB RAM, GeForce4 64MB, Audigy Platinum
http://www.breakbeat-terrorism.co.uk
(It's not all about the coding)
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 3rd Jul 2003 20:21
You shouldn't have a problem with types in an included file - they work fine when I use them - for an example, see the 'Fast A*' code in code snippets.
Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 3rd Jul 2003 20:36
Forget types! lol. I'm still having problems with variables!

-I have a function "InitialiseCollision()" in my included file.
-First thing I do is run "InitialiseCollision()" in my main source.
-All the array definitions in InitialiseCollision() are all prefixed with "global". e.g.
global Dim BounceCollisionXSpd#(1) as float
-This is compiles fine and works, but whenever I try and reference them from within the main source file, it doesnt work.
Example:
position object 1, SlidingCollisionX#(1),SlidingCollisionY#(1),SlidingCollisionZ#(1)

These variables exist and are defined. It doesnt even say they're not, the actual error is:
"Parameters for "Position Object" do not match format blah blah blah"
Its blatently the right formatting. I can retrieve info from the variable using an assignment statement:
a# = SlidingCollisionZ#(1)
Although I havent tested to see if they're actually successfully holding values.

Basically, I dont know whats going on! Anymore ideas? I dont want to have to assign all my variables into temporary variables before I use them in other statements. I kinda have the feeling the variables wont be holding the values properly either.

Machine: P4 2200, 1GB RAM, GeForce4 64MB, Audigy Platinum
http://www.breakbeat-terrorism.co.uk
(It's not all about the coding)
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 3rd Jul 2003 20:55
I suspect that you are defining your arrays *within* your function in the same way that Raven was declaring his globals within his function.

I suggest you look at the A* code and see how I did it. That uses array, globals and types all over the place, and it all works perfectly whan included

http://www.darkbasicpro.com/apollo/view.php?t=11137&b=6
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 3rd Jul 2003 21:39
yeah but you have to admit it is annoying not to be able to do these things which should work.

atleast Lee says he's fixxed it

APEXnow
Retired Moderator
23
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 3rd Jul 2003 21:59
Raven, just curious but why the sudden change in avatar and signature etc. Hard job finding your posts these days LOL, always looked out for the old avatar etc.

Soz for subject deviation!

MSI/AMD Athlon 1300, 256Mb, 60GbHD, SoundBlaster Live!, GeForce 4 MX440-64Mb, Win2K, DX9, DarkBASIC Pro(PUv4.1)
Rob K
Retired Moderator
23
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 3rd Jul 2003 21:59
All arrays are global, there is no need to use GLOBAL DIM arrayname()

Do you want Windows menus in your DBP apps? - Get my plugin: http://snow.prohosting.com/~clone99/downloads/tpc_menus_103.zip
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 3rd Jul 2003 23:48
Rob its good practise to use global & local when describing your values if that is what they need to be.
It also conserves the memory better because the values then have strict rules rather than being open

don't worry my av will probably be going back to Vegeta again soon, it just my character for 7dp up there cause i likes her.
i didn't notice until last night that i've made her look so similar to one of my mates, she was all like "hey this kinda lookes like me" ... i was "oh yeah, wonder why" hehee

i have so many cute friends

APEXnow
Retired Moderator
23
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 3rd Jul 2003 23:55
LOL, cute friends with massive strapping hardware to kick some serious bootie? hehe.

MSI/AMD Athlon 1300, 256Mb, 60GbHD, SoundBlaster Live!, GeForce 4 MX440-64Mb, Win2K, DX9, DarkBASIC Pro(PUv4.1)
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 4th Jul 2003 00:03
Quote: "massive strapping hardware"

lmao... she's nothing like the game character unfortunately, personality wise she is... but she doesn't like guns, can't fight to save her life, she is a vegan (so can just imagine how much energy she has lol).

apart from being looks and smoking the similarities stop there, but i'm hoping to coax her into moving over to the west coast get her into a few things (like MEAT! lol) ... sides its always nice to have a cute girl around the house that isn't like a big sister to me lol

APEXnow
Retired Moderator
23
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 4th Jul 2003 00:32
LOL, ahhh haa, so it wasn't just the cooking then? JKM

Will admit, I've never been happier since meeting my better half, been together, (Married now) for three years

MSI/AMD Athlon 1300, 256Mb, 60GbHD, SoundBlaster Live!, GeForce 4 MX440-64Mb, Win2K, DX9, DarkBASIC Pro(PUv4.1)
Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 4th Jul 2003 00:42
get her into a few things (like MEAT! lol)

Get some meat into her, eh?

.. uhhhh

I'll quit while I'm ahead.

Machine: P4 2200, 1GB RAM, GeForce4 64MB, Audigy Platinum
http://www.breakbeat-terrorism.co.uk
(It's not all about the coding)
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 4th Jul 2003 05:58
well i've been told she's never had any good british beef ... so that something i'm going to have to give her when she come over to stay (hehee maybe i should quit now too lol)

Nilrem
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 4th Jul 2003 12:15
Fallout beat me to it!

I hear and I forget. I see and I remember. I do and I understand.
adr
23
Years of Service
User Offline
Joined: 21st May 2003
Location: Job Centre
Posted: 4th Jul 2003 12:22
/me shouts out some funny words that you only hear on late night TV.

ARGH! Last night, I decided to collapse my entire game into one source file because of the problems I was having with #include/Add File ...
Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 4th Jul 2003 21:45
To be honest, its not exactly a problem with db though, seeing as you can collapse your functions making them one line each, which solves the mess issue. Well, it would if the collapsing of functions worked.

Machine: P4 2200, 1GB RAM, GeForce4 64MB, Audigy Platinum
http://www.breakbeat-terrorism.co.uk
(It's not all about the coding)

Login to post a reply

Server time is: 2026-07-17 13:57:04
Your offset time is: 2026-07-17 13:57:04