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 / HELP - How Do You Work With SOURCE FILES?

Author
Message
CD On CD
21
Years of Service
User Offline
Joined: 23rd Sep 2002
Location: United States
Posted: 27th Sep 2002 09:52
hi all

i know it's probably an easy task but for some reason or another i just can't get it going right now when working with INCLUDED files (maybe it's just to late, or early in the morning)

here's what i mean:

1):
i have the MAIN SOURCE FILE called "main.dba"
within this MAIN file of course i have some general startup code, etc.

2):
i then ADD another file under the INCLUDED SOURCE FILE & named it "level1.dba"
within this source file would be "Level 1" & asociated code, etc.

3):
now, what IF i continued adding additional source files (level2,dba, level3.dba, etc)

4):
THE PROBLEM:
how do i from the MAIN file call these INCLUDED SOURCE FILES and then get back to the MAIN file safely?

i have tried this:
#include "level1.dba"
level1 ()
etc.

nothing works. it is late but if anyone could tell me, or better yet make a quick example that calls diferent INCLUDED FILES would be great. i know it cant be that hard of a thing....is it?

thanx in advance
United We (Still) Stand
MrTAToad
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 27th Sep 2002 12:16
If the incldued files contain functions, then you should just need to call it with the function name.

Likewise if they just contain labels...

Yes, I really am THAT good...
CD On CD
21
Years of Service
User Offline
Joined: 23rd Sep 2002
Location: United States
Posted: 27th Sep 2002 19:46
yes, the INCLUDED file is simply a FUNCTION.
something like this:

IN THE MAIN SOURCE FILE (called main.dba)
#include "source.dba"
source ()
wait key

IN THE INCLUDED SOURCE FILE (named source.dba)
function source.dba ()
print "hello world"
endfunction

when run i just get a black screen

see what you get from these all too simple script
if anyone has an example (in zip form) i learn more from seeing

thanx

United We (Still) Stand
Zep
21
Years of Service
User Offline
Joined: 31st Aug 2002
Location: From PA, USA. Currently reside in Hanoi, Vietnam
Posted: 27th Sep 2002 20:06
well, if that's how it is, it's not right

should look more like this

#include "source.dba"
source()
wait key

IN THE INCLUDED SOURCE FILE (named source.dba)
function source()
print "hello world"
endfunction


Zep--

waffle
21
Years of Service
User Offline
Joined: 9th Sep 2002
Location: Western USA
Posted: 27th Sep 2002 20:50
actually, the #include is redundant. All project files are merged into one file at compile time. So, if you just treate the project just as you would a single file, you got it. So you could gusub to any label or call any funtion from anywhere in any module. To view the project construction order, just view the file list. Main comes first, then each of the others in the order listed.
CD On CD
21
Years of Service
User Offline
Joined: 23rd Sep 2002
Location: United States
Posted: 28th Sep 2002 18:09
thanx to all for your replies !

it's weird (i guess) but the ONLY way this worked in the Pro version is to NOT use the #INCLUDE statement!

if i use what "waffle" said w/o that #include statement it works perfectly and when i DO use the #include statement it errors in different way EACH time it's run....weird? or a bug?

United We (Still) Stand
deadlyduck
21
Years of Service
User Offline
Joined: 19th Sep 2002
Location: United Kingdom
Posted: 28th Sep 2002 18:45
the problem your having is you have already included the source file by using the add code button, so in effect using the #include is adding the file again so the compiler is prolly getting confused, Its prolly worth reporting this to DB support as there should be a check for it

Login to post a reply

Server time is: 2024-04-27 02:40:04
Your offset time is: 2024-04-27 02:40:04