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 / User-defines functions that return values

Author
Message
EvilKnuckles 666
21
Years of Service
User Offline
Joined: 23rd Jun 2003
Location:
Posted: 19th Nov 2003 05:08
ok, i'm stuck, i have a function that needs to return a value as the actual function name. i was wondering if that's even posible. i know it is w/ functions that are pre-defined (timer(), strite x(), etc...) but i need to do that w/ my function.

I need to have a conditional where it figures
CheckCollision(SpriteClass)=1
but it won't asign a value to CheckCollision.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 20th Nov 2003 19:39
The first one is easy ... The return type is determined by the type of the parameter after the ENDFUNCTION command



The same goes for your second function ... except that DBPro cannot return a type at the moment.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 21st Nov 2003 10:42
any idea if patch 6 will allow you to return a TYPE?
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 21st Nov 2003 14:10
Nope, no idea, but I certainly hope so
EvilKnuckles 666
21
Years of Service
User Offline
Joined: 23rd Jun 2003
Location:
Posted: 24th Nov 2003 22:31
IanM, i'm talking about returning a value for the actual function name: "CheckCollision"

Such as
Endfunction CheckCollision
^is that possible?
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 24th Nov 2003 23:36
no. dbp functions are not like c/vb functions where the name is the return. If you want to you can make the variable Global so the function can act on it, and "return" it.

-RUST-
EvilKnuckles 666
21
Years of Service
User Offline
Joined: 23rd Jun 2003
Location:
Posted: 25th Nov 2003 22:09
how would i make it global?
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 25th Nov 2003 22:35
Global intMyVar As Integer

-RUST-
EvilKnuckles 666
21
Years of Service
User Offline
Joined: 23rd Jun 2003
Location:
Posted: 29th Nov 2003 07:41
what does making it global do to it?
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 29th Nov 2003 11:42
Variables used within functions are private or local by default. Meaning that variable only exists within that function. By declaring it global, state that the variable is seen by all functions in the program.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 29th Nov 2003 14:37
This snippet shows you local and global variables in use - NOTE, it's not meant to be run



Make sure that you name your variables very carefully. Using the code above, the logig would change drastically if you suddenly made the variable 'a' a global. That's why I get into the habit of doing the extra typing and declaring all my local variables

Login to post a reply

Server time is: 2024-09-21 11:38:28
Your offset time is: 2024-09-21 11:38:28