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 / UDT Return From a Function

Author
Message
SunDawg
21
Years of Service
User Offline
Joined: 21st Dec 2004
Location: Massachusetts
Posted: 10th Jul 2010 07:42
As far as I can tell there is still no support for returning a user defined type from a function. Does anyone have an effective workaround for this issue?

If you aren't sure what I'm talking about, I wrote up a quick snippet explaining it.



My site, for various stuff that I make.
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 10th Jul 2010 13:04 Edited at: 10th Jul 2010 13:05
I think the easiest way is to use a global of that type and fill it in the function. After calling the function you can use that global.

Cheers!
Sven B

gamerboots
17
Years of Service
User Offline
Joined: 8th Dec 2008
Location: USA
Posted: 10th Jul 2010 16:36 Edited at: 10th Jul 2010 16:39

interesting. I confirm that it does compile when using structures as parameters in functions and that functions can recieve and use structures when they are passed or created as parameters.
but declared structures cannot recieve a return structure from a function due to compiler error (NOTE the print statements within the function)

the question is when did it happen that functions can use UDT's as parameters or did I miss reading something ?



----------------
Gamerboots~
SunDawg
21
Years of Service
User Offline
Joined: 21st Dec 2004
Location: Massachusetts
Posted: 10th Jul 2010 18:59 Edited at: 10th Jul 2010 19:00
I did the global method to example how it could be worked around. You can see with only the potential for three windows how much bloat it adds.


Some debugging/optimization was done to make dragging the windows feel more natural.


My site, for various stuff that I make.
Benjamin
23
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 10th Jul 2010 21:40
It's an unfortunate limitation but we probably won't ever see it implemented since Lee worries about breaking the compiler.
Zotoaster
21
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 10th Jul 2010 21:50
Someone needs to completely rewrite the DBP compiler and make it backwards compatible. That would be cool. Ben, I appoint you to this task.

"everyone forgets a semi-colon sometimes." - Phaelax
Kevin Picone
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 10th Jul 2010 22:04
Somebody mentioned this to TGC once..

Benjamin
23
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 10th Jul 2010 22:14
Quote: "Someone needs to completely rewrite the DBP compiler and make it backwards compatible. That would be cool. Ben, I appoint you to this task."


I'd love to, but I doubt I'd get any compensation for it even if TGC were willing to use it. I think they've shifted their focus more onto game development applications rather than languages, which is a shame.
gamerboots
17
Years of Service
User Offline
Joined: 8th Dec 2008
Location: USA
Posted: 10th Jul 2010 23:26 Edited at: 10th Jul 2010 23:53
hi SunDawg,
ouch, looks like your doing this the hard way
why not make your window properties into a single dynamic array and use one function to initialize,drag, or whatever with your windows ? here is a skeleton for you to play with that will take a lot of the headache out of this as you will only have to code some things once in place of 30 times.



hope this helps you out.

----------------
Gamerboots~
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 12th Jul 2010 22:45
Quote: "the question is when did it happen that functions can use UDT's as parameters "


At least a few years now, if not always. Pretty sure I've been passing them into functions for awhile now.


"Any sufficiently advanced technology is indistinguishable from magic" ~ Arthur C. Clarke
gamerboots
17
Years of Service
User Offline
Joined: 8th Dec 2008
Location: USA
Posted: 13th Jul 2010 01:56
well I missed the boat on that one. lol my bad.

----------------
Gamerboots~
Alfa x
20
Years of Service
User Offline
Joined: 1st Jul 2006
Location: Colombia
Posted: 13th Jul 2010 20:04
Hi,
I have a plug-in that can help you with your problem.
You can have arrays inside arrays (if you use them correctly, they can be useful for your problem too).

I can finish the dll if you need.

Code example:

Login to post a reply

Server time is: 2026-07-25 07:54:46
Your offset time is: 2026-07-25 07:54:46