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 / Calling Functions

Author
Message
lcfcfan
23
Years of Service
User Offline
Joined: 19th Feb 2003
Location: North East, UK
Posted: 17th Aug 2003 22:41
I have made a function to control camera and included it in my program using #include "control.dba" how do i call the function i tried using the function name control() but it said unknown command.
lcfcfan
23
Years of Service
User Offline
Joined: 19th Feb 2003
Location: North East, UK
Posted: 17th Aug 2003 23:38 Edited at: 17th Aug 2003 23:38
Here is my function code



Dr OcCuLt
23
Years of Service
User Offline
Joined: 27th Nov 2002
Location: a Dark Deep Dark pit, it dark in here
Posted: 18th Aug 2003 00:01
what are u uesing DB or DBpro

this is how functions


if your uesing classc is your #include file in the same floder as the main file.

if your uesing pro ues the browse in the file source file bar to add the #include file.

--Dr 0--
lcfcfan
23
Years of Service
User Offline
Joined: 19th Feb 2003
Location: North East, UK
Posted: 18th Aug 2003 00:17
i'm using pro and it is in the same folder, i did what you said using the browse to add the file i wanted included but when it does not work!

Here is my code!




And my function code again!



Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 18th Aug 2003 01:14
I heard that the #include function should not be used, as it doesn't work (great isn't it?). I think you're just supposed to add the source file using the dbpro editor "Files" tab.

Insiiiiiiiiiiiiiiiiiiiiiiiide!
CattleRustler
Retired Moderator
22
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 18th Aug 2003 01:51
I posted a Function explanation in another thread that I forgot the name of...It was someone talking about DB tutorials or help files and you said something about just trying to understand functions - see if you can find it, I think it will help. I looked at your function code and you really don't need a function at all. You are not passing in any arguments, nor are you trying to return any so in this case I would use a subroutine. Just use...

MySubroutineName:
~~da codez~~
Return

you call your routine from code GOSUB MySubroutineName

functions are called on the right side of an equation because they usuall return a value that you intend to set on the left side of the equation like:

MyVariable=MyFunction(arg1,arg2,..argN)


RUST-

How do ya do there son
CattleRustler
Retired Moderator
22
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 18th Aug 2003 01:55
The post is in GENERAL forum under CodeNation--> DB Tutorial

I explained functions there

good luck
Rustler

How do ya do there son
lcfcfan
23
Years of Service
User Offline
Joined: 19th Feb 2003
Location: North East, UK
Posted: 18th Aug 2003 02:23
Thanx Castle Runner!

lcfcfan
23
Years of Service
User Offline
Joined: 19th Feb 2003
Location: North East, UK
Posted: 18th Aug 2003 02:26 Edited at: 18th Aug 2003 02:27
Er kinda works but the mouse movements no longer work properley it's really jerky and keeps puuting it back back to the original position!

the_winch
23
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 18th Aug 2003 02:33 Edited at: 18th Aug 2003 02:34
One thing to remember about functions is that you can only access variables that are outside of the function if they are global.
So

do
move()
sprite 1,x,y,1
loop
function move()
x = mouse x()
y = mouse y()
endfunction

Won't work but

global x as integer
global y as integer
do
move()
sprite 1,x,x,1
loop
function move()
x = mouse x()
y = mouse y()
endfunction

Will.
CattleRustler
Retired Moderator
22
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 18th Aug 2003 03:41
no prob


How do ya do there son
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 18th Aug 2003 03:43
#INCLUDE *does* work ... as long as you use full pathnames.

Here's one of the shortest, most feature rich programs I've written to date :



Login to post a reply

Server time is: 2026-07-23 00:54:45
Your offset time is: 2026-07-23 00:54:45