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 DBPro Corner / Duplicated function name

Author
Message
jobromedia
11
Years of Service
User Offline
Joined: 9th May 2012
Location: Stockholm, Sweden
Posted: 21st May 2012 19:22
Having a hard time understanding functions here. I\'ve read the TDK tutorial on functions, but still I\'m getting the infamous duplicated function name:

Quote: "The name \'prepend\' duplicated in the program inside jbmfunc.dba."


Here is the main program:



And here is the jbmfunc.dba file:



Now what is wrong here?

MIDI packs for sale.
Best regards
Johan Brodd
nonZero
12
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 21st May 2012 20:21 Edited at: 21st May 2012 20:23
Quote: "#include \"jbmfunc.dba\""

should be something like:


or, if it's not located in the same folder:


MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 21st May 2012 21:06
you could use a plugin like STYX or possibly Matrix1Utils from ianM to automatically identify the install path and then place the \filename.extension after it as a whole string

just a thought...

Kezzla
15
Years of Service
User Offline
Joined: 21st Aug 2008
Location: Where beer does flow and men chunder
Posted: 22nd May 2012 00:56
also, if you have included the extra dba file using the IDE the file will automatically be included and there is no need to use the include command.
try removing the include command and see if it works then.

Sometimes I like to use words out of contents
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 22nd May 2012 01:23
It's funny, when I tried it using your code, the error given was 'Failed to unfold includes'. NonZero is correct, you did not use correct syntax when including the file.

Another way you could do it is to get rid of the include file and put it all in one .dba, like this:



So many games to code.......so little time.

nonZero
12
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 22nd May 2012 12:19
Quote: "also, if you have included the extra dba file using the IDE the file will automatically be included and there is no need to use the include command."

Yeah, on that note...
If you are using the new editor - that's the one that looks a little like Visual Studio (It does, let's be honest) - then you should use Kezzla's suggestion and add the included files using the GUI rather than code. There ia a bug in the new editor which has still not been corrected that makes it neigh on impossible to use the #INCLUDE command in any case (Which is fine for people who got used to a mouse but sadly I never did).

If you are using the old editor - that's the one that looks like Dark Basic Pro's editor (It really does. Shockingly so. In fact they're identical ) - then you can just use #INCLUDE as usual without the hindrance of all the hassles that the new editor brings. IMHO, the new DB editor looks nice but seriously lacks in simplicity of functionality which is why I use the old editor to this day... Or it could just be I hate change, I hate not doing things my way and I'm a retro guy to begin with

Quote: "Another way you could do it is to get rid of the include file and put it all in one .dba, like this:
"

This is by far the best suggestion for your case. Unless you have a function library of re-usable functions that you use wish all your projects then you don't need separate files for your functions. All that happens when you #INCLUDE a source file is that the code is appended to the bottom of your main source (at precompile so it won't affect performance either way). There is one other time you may find splitting your main code up into seperate #INCLUDE files and that is when you want to make it more manageable for yourself. I personally still maintain that if you keep your code neat and well ordered, you need not split your main source into pieces (with regard to DBP). But each to their own. At the end of the day, it's a balance of what makes you most comfortable and what's most expedient that you should decide as you method of doing things.

Kezzla
15
Years of Service
User Offline
Joined: 21st Aug 2008
Location: Where beer does flow and men chunder
Posted: 22nd May 2012 14:36
yeah, I figure with the duplicate function name error, that was the reason. that's the error I get when I add a dba file and then try to include it using #include.

I just add my functions library with the ide and have no problems.

Sometimes I like to use words out of contents

Login to post a reply

Server time is: 2024-04-27 11:22:47
Your offset time is: 2024-04-27 11:22:47