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.

Author
Message
Darth Coder
23
Years of Service
User Offline
Joined: 30th Mar 2003
Location: Switzerland
Posted: 1st Apr 2003 03:30
Is there a "reference" type in DBPro? That allow to make references to custom type variables?

I think not cause in another thread someone said you couldn't pass a custom type as an argument to a function and that would solve that problem.

So that would mean that currently DBPro only supports a kind of "global variables and gosubs" style of programming. That's a bit disapointing

I hope I'm wrong or that this feature will be added (btw if you could put some object oriented programming with that as well
"You don't know the power of the Dark Side." - Darth Vader
Shadow Robert
23
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 1st Apr 2003 05:37
hmm ... i have a feeling i know you from somewhere

well anyways, right now Pro only support Global & Private data types - IE the types are either Globally used or Privately used (within a function)

however that said you can use the memory command to create a small block of memory which can then be passed into a function like variable with a pointer
its a tricky practise, and i've not achieved it sucessfully myself - but i'm sure it is possible

personally i'd love to see data types being setup more closely so we can pass them using Functions - it'd certainly help alot of my math functions.
i have found passing them into a DLL with a memory pointer generally helps too - cause it gives you a bit more freedom, but kinda defeats the point the the exercise of using DBpro lol

you know i've not tried yet, but perhaps you can setup a pointer to the Types?
perhaps


something like that i'd imagine would be oki

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?
Darth Coder
23
Years of Service
User Offline
Joined: 30th Mar 2003
Location: Switzerland
Posted: 1st Apr 2003 19:13
From the doc:
You can only use a standard variable with indirection, and array and type variables are not valid.



So pointers are not very useful and it's impossible to do real data structures in DBP. There is simply no type associated with the pointer. In C terms they are all "int *". If you could just do have pointers to arrays and types, then it would be possible to do complex data structures and to do much cleaner code.

But references would be better than pointers for newbies as they are "fool-proof". I really hope that language will evolve as these features are much needed to be able to do more complex projects.

"You don't know the power of the Dark Side." - Darth Vader
madbilly
23
Years of Service
User Offline
Joined: 20th Mar 2003
Location: United Kingdom
Posted: 1st Apr 2003 21:30
I've made custom memblock areas in the same format as a custom data type would be, then made a memblock for each new instance of the "type". The type variable can then be accessed using the memblock number. e.g.



Hope you get the idea and that it helps.

Will
Darth Coder
23
Years of Service
User Offline
Joined: 30th Mar 2003
Location: Switzerland
Posted: 1st Apr 2003 22:08
Thanks madbilly.

I thought of that but I don't really see the point of using a basic if it's to use such kind of syntax. It can be useful to solve one problem if there is no other way, but that's not going to be the way I write thousands of lines of code.

One solution could be to use a preprocessor to convert a nice syntax to this, and then let darkbasic compile the result. Or maybe a combination of a preprocessor and a plug-in?

But that will take some time and right now, I need to do my retro competition entry. So I'll do everything with global arrays and gosubs. (It seems patch 4 fixes the bug that prevents me to accessing the global arrays of types from within functions. So if I receive my full copy before the end of the week, I might at least start using functions )

"You don't know the power of the Dark Side." - Darth Vader

Login to post a reply

Server time is: 2026-07-21 20:34:22
Your offset time is: 2026-07-21 20:34:22