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 Discussion / Dynamic #Include Question

Author
Message
Nosnevel Xela
20
Years of Service
User Offline
Joined: 14th Dec 2004
Location: MA, USA
Posted: 4th Jan 2006 04:07
Hello. I've searched the forums, but I haven't found anything that mentions this.

I started a club at my school, and we are creating a fps with a fantasy rpg setting. You can play as either a wizard or a worrior, and cast spells / hit people with your sword etc.

What I wanted to do, so that we could easily split up the code amongst ourselves, as well as make it easy to build in pieces, was to put all the functions in seperate .dba files and then include them. For example, I would have a 'spells' folder, and in it would be a bunch of .dba files, each containing the code necesary to execute that particular spell.

I then want the code to look in the spells folder, and #include all the .dba files. I wrote some code that looked up all the file names, checked if they ended with .dba, and then included them. The problem is, it doesn't seem like you can #include a variable, but must #include an absolute string.

In the simplest form, here's where I find the problem:
This works:

and this doesn't


If I could somehow get the 2nd example to work, then I'd have no problems, I could use my code to find the .dba's and include them. The reason for all this is so that, to add another spell, all i have to do is put the code in a .dba file, and throw it in the 'spells' folder, without code change to the main program.

Thanks!

I am who I am
Lost in Thought
21
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 4th Jan 2006 04:55
I am at work so I can't test but have you tried making the string variable a constant?

Nosnevel Xela
20
Years of Service
User Offline
Joined: 14th Dec 2004
Location: MA, USA
Posted: 4th Jan 2006 05:56
What exactly do you mean by a constant?

I have replaced the variable with a file path in " "s, which works, but as soon as I substitute it as a variable, it stops recognizing my functions.

I am who I am
Atreides
21
Years of Service
User Offline
Joined: 11th Oct 2003
Location: Switzerland (but NOT on a mountain !)
Posted: 4th Jan 2006 16:54
Hmm... you could try that :

Make a program which perform the checklist for files, finds all .dba and then write a "include.dba". Include the include.dba which includes everything you need.

That would be something like that :


And everytime you add a file in the directory, you run this program...

The sleeper must awaken !
blanky
20
Years of Service
User Offline
Joined: 3rd Aug 2004
Location: ./
Posted: 4th Jan 2006 18:45
Quote: "
srcpath$ = "C:\db\myfunctionsfile.dba"
#include srcpath$
"


No. It just doesn't work like that.

When DBC compiles a program, it looks for #includes, and shoves the end of those files onto the main file & compiles the result as one program, removing even the #include commands themselves from the EXE.

You'll have to write something along the lines of a basic interpreter, or just hardcode everything in.... either that, or try and sleep peas and cheat and use DLLs and stuff. Hasn't been done before (dynamic linking) in DBC, a DLL written in another language is the cloest you're gonna get unless you're really really good.

With your particular setup, it could be easier to just write a quick BATch script so that anyone can double-click it & re-compile the latest version of the game.

If your problem is that you only have one copy of DBC on one machine, you could either whip up a quick program that lets people have a button to make the 'server' compile the latest build of the game or just give up and let them compile it themselves.

With regards to any of these options, I feel pretty hardcore at the moment and would provide some sort of support (in this thread) for whatever options you choose. Just laying them out in front of you right now.

Support the AAANJL by doing nothing! Visit teh site below..
Nosnevel Xela
20
Years of Service
User Offline
Joined: 14th Dec 2004
Location: MA, USA
Posted: 4th Jan 2006 19:48
Thanks Everyone

I think I'll write a batch file or visual basic or something to make a list of #include files and save that as a .dba, and include that into my program. (sort of as suggested by Atreides)

I'll post when I'm done
Thanks

I am who I am
Nosnevel Xela
20
Years of Service
User Offline
Joined: 14th Dec 2004
Location: MA, USA
Posted: 5th Jan 2006 00:25
Problem Solved!

I wrote a quick visual basic application that finds all the files to be included, takes the code out of them, and pastes it into one single .dba file called IncludeFunctions.dba

I can then simply #include "IncludeFunctions.dba" in the main program.

Thanks

I am who I am

Login to post a reply

Server time is: 2025-05-23 04:27:45
Your offset time is: 2025-05-23 04:27:45