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 / Passing TYPE to a function

Author
Message
Bulleyes
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Cyberjaya, Malaysia
Posted: 3rd May 2003 06:23
Hi, I heard that there is no way to pass a TYPE as parameter to a function in DBpro. If this is true, is there anyway I can do something like this,

1. I create a TYPE.
2. I need to call a function.
3. This function will modify the properties in the TYPE that created in Step 1.
4. When the function exits, the properties of the TYPE were modified accordingly as done in Step 3.

I know I can make the TYPE global, but that doesn't work in my case. The function need to be able to modify any instance of that TYPE as specified by the function caller.

Any ideas? Thanks!
Bad Nose Entertainment - Where games are forged from the flames of talent and passion.

http://www.badnose.com/
indi
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 3rd May 2003 07:50
arrayed types will pass into a function as a paramter.

Monster(1).NUM as an example.

Ive posted an example for typed arrays in the code snippets board.

indi
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 3rd May 2003 10:45
see example below for a closer snippet

Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 3rd May 2003 12:31
this is kinda what we've been asking DBS to put on thier things-to-do-soon list...

i know they want to get all the 3D and such working spick&span, but personally i'd prefer a more stable and indepth language there so we have the option of creating our own stuff on the 3D Front than having to use not quite right functions with no way of creating our own.

i've been trying to work on a way around it, but isn't getting anywhere very fast - because there is no way to determine type casting
the only current way to really achieve it is by hardcoding each type you make using a memory pointer - i'm sure there is a better way to achieve is but as of yet i'm not sure how.

currently Ian has made this for the sorta thing you mean


it would be possible to develop an editor which would be able to be recoded and use this with the object orientation that current types use ... but without a way of determining what the next section of data is setup in there is no real way to make this a universal setup right now for some true passing

a good example of howto use this would be like this


pretty cool eh

Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 3rd May 2003 14:56
Well, it works at least. I'd much prefer to use something other than low-level memory access.

Try something like this instead - it uses arrays to simulate memory allocation:



This is how you would use it:



There are a lot of things missing:
Allocation of an 'array' of types
Releasing memory back to the OS
Constructors/Destructors/Copiers
Type safety
+ others

Now Raven, about that code translator of yours ... I'd love to be able to put 'x.x=1' instead of 'MyType(x).x=1'. How about it?
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 3rd May 2003 15:53
hmmm... well i'm gonna grab a few hours sleep
but i'll see about doing that - one of the things i've been working on in particular is an inline Function Declarer,

so you'd use it like


just a simple example, but i think it'd allow for what your asking

Tsu'va Oni Ni Jyuuko Fiori Sei Tau!
One block follows the suit ... the whole suit of blocks is the path ... what have you found?

Login to post a reply

Server time is: 2026-07-10 23:13:59
Your offset time is: 2026-07-10 23:13:59