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 / DB Pro Trial - Function in include file acting buggy... Ideas?

Author
Message
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 11th Jun 2007 04:49
Greetings All, and first off let me say I appreciate your help and suggestions.

Problem: DB Pro Trial, Simple 2 Source file Program.

Error Message during Compile: The Function 'HelloWorld' duplicated in the program inside testinclude.dba.

Source code #1:
-------------------------------------
#include "testinclude.dba"
CLS
HELLOWORLD()
End

Source Code #2:
-------------------------------------
Function HelloWorld()
Print "Hello World"
wait key
endfunction


Possibly Helpful Note: When I FIRST entered the program, it worked. I added: GLOBAL A$ above the Call to HelloWorld in source file #1, because I was going to test variable scope. I recieved the error and subsequently deleted the GLOBAL A$ line. The error remained. This peculiar behavior prompted me to post this question.

---Non-Related:
Below is not Question Related but may be of interest. The rules said don't make multiple threads if not necessary etc.

I bought DB Pro like 4 years ago I think, and I have not used it in eons. I saw some new things recently from TGC, and thought I'd dig it up - couldn't find my software cd's - so I downloaded the trial. I'm trying to reaquaint myself - and this is proving difficult because the first thing I always do is start an API and/or tool box to help when I'm knee deep in an application later. Building functions and understanding variable scope so I implement thing correctly is key to working with the system versus fighting it.


Note: I am a professional programmer, but do games for fun. My point is that I am not a newbie choking on a string without quotes or something like that, or a Variable named HelloWorld as well as a function (Even though some languages don't mind) though I am not immune to such errs, that is why I'm asking you for a second pair of eyes to potentially spot something silly I'm doing or confirm to me the code looks correct.

Also, I'm looking VERY CLOSELY at the new DarkGTK. It looks nice. I am perplexed why they do not bundle the .net and C++ versions together, but that is neither here nor there... WHAT IS HERE ANd THERE is the improved speed. I'm thinking possibly of purchasing and, if allowed, making FreePascal units that allow using library from it versus C++. (FreePascal Kicks - but finiding equivalents for existing C++ header files is difficult sometimes).

Any ways thanx in advance for helping with my problem.

Know way to many languages - Master of none
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 11th Jun 2007 06:50
Maybe you should include testinclude.dba in the dbpro project file instead of having a #include line in your first program. (Use the Files button - bottom right).

AFAIK, DBPro's project file made #include obsolete.

TDK_Man

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 11th Jun 2007 14:45
TDK is right. Comment out the #include line and it should just work. You are effectively including the same file twice.

jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 11th Jun 2007 14:51
Thank You Very Much! It was a simple oversight on my part! Thank you.

Now I can start organizing my code in a more logical fashion.

The Following code worked just fine:

File #1
-----------------
CLS
GLOBAL A$=" Dude"
HELLOWORLD()
WAIT KEY
ANOTHER()
WAIT KEY
END
------------------


File #2
------------------
Function HelloWorld()
Print "Hello World" + A$
endfunction


Function Another()
Print "another One"
endfunction
------------------

P.S. The CODE tag in this forum, when you click the CODE button makes only one tag. What is the Closing Tag? I presume its the same thing but a forward slash after the first bracket.... so if you have a second and know - share this tip - it will help me post code correctly if you do. Thank you in advance.

Know way to many languages - Master of none
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 11th Jun 2007 15:56
Two ways to do it:

1. Click the Code button and it creates an open code tag. Paste your code into the text box. Click the Code button again and it adds the closing tag.

2. Paste your code into the text box. Highlight all of it with the mouse. Click the Code button.

Method 2 is probably the way most of us use it most.

TDK_Man

Login to post a reply

Server time is: 2024-11-25 18:05:46
Your offset time is: 2024-11-25 18:05:46