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 / Linking several souce codes together

Author
Message
CaiF_R
22
Years of Service
User Offline
Joined: 25th Jan 2003
Location:
Posted: 2nd Feb 2003 07:06
How do i link several souce codes together?
I´ve tried with #include in what i call the main souce code and then made that specific code a function that could be called from the main souce but under excution it just generates a "severe error" or something just as bad. Are there any alternatives?
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 2nd Feb 2003 08:03
DBC

includes hold functions

these functions are local only and if u made something inside it like say an array its local only to that function

declaring variables like arrays are the only global variable in DBC


using the include command to store all your premade functions so your main isnt very longwinded


DBP


u can use the global command to make a variable global so it passes through a function

includes hold functions and gosubs

The differences here is u can use the command include or using the project manager.

indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 2nd Feb 2003 08:03
oosp typo or mis information

declaring variables like arrays are the only global variable in DBC if declared in the main at the top

CaiF_R
22
Years of Service
User Offline
Joined: 25th Jan 2003
Location:
Posted: 2nd Feb 2003 09:57
Hmm... i donno if i gave the wrong info (iam danish so its quite hard to explain)
Here goes: I want a "main souce code" wich calls other "souce codes" when they are need. Ex. a intro souce is need in the beginning of a game and then the souce for a menu afterwards. I dont have any trouble with just clip/paste the code together and i dont know if the method i explained above is commonly used but i just thought it was easy to seperate the code in small pieces so it would be easy to change something in the "intro" bit of the code (ect. change a bitmap/image) or wich options to display in the "menu" piece ect.

Hope that cleared things up

Cheers

indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 2nd Feb 2003 12:26
store what u want in fucntions and follow the rules provided above to include anything.

CaiF_R
22
Years of Service
User Offline
Joined: 25th Jan 2003
Location:
Posted: 2nd Feb 2003 15:41
So what u are saying is that it doesnt actually have to be a function... that i can "cheat" db into thinking its a function? Brb then... have to try it
Thanks!

Cheers

indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 2nd Feb 2003 17:10
if your using DBP it has a few extra features.

CaiF_R
22
Years of Service
User Offline
Joined: 25th Jan 2003
Location:
Posted: 3rd Feb 2003 07:39
Thanks indi.
But iam stuck (for now that is) with db but see if I work aound it somehow

indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 3rd Feb 2003 08:05
place a function in an include file

call this include at the top of a main file

if its DBP u need to make a project folder and project file.

use the function in your main after this like its part of the code but sourced from the include.

Login to post a reply

Server time is: 2025-08-08 11:44:51
Your offset time is: 2025-08-08 11:44:51