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 / Questions about arrays in Darkbasic Pro

Author
Message
Reek
13
Years of Service
User Offline
Joined: 21st Aug 2011
Location:
Posted: 22nd Aug 2011 05:47
Hi Guys, I have a couple of questions about Arrays in Darkbasic pro

1. Can I declare an unknown size multi-dimensional global array ?
2. Can I pass a multi-dimensional array to a function ?

I tried to work it out myself but it doesn't seem to work...
Code examples will be appreciated.

Thanks
WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 22nd Aug 2011 13:18
1. Yes... Global Dim arrayname() as UDT
2. If you declare an array as a global it is much more efficient to pass an element number to a function or just let the function use the array as a global.

1. (again) It's probably best to use UDT's (User defined types) instead of multidimensional arrays if you can.


Warning! May contain Nuts!
MummyKillerSLO
15
Years of Service
User Offline
Joined: 5th Jul 2009
Location: Object Position Y(ObjChair)
Posted: 22nd Aug 2011 21:07
As I know, all DIM arrays are global so you can just put:



Happy to having and using DarkBASIC Professional...
WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 22nd Aug 2011 21:51
If you define a dim'd array inside a function then it's local only unless you specify 'global'.

Warning! May contain Nuts!
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 22nd Aug 2011 21:55
Quote: "1. Can I declare an unknown size multi-dimensional global array ?"



Quote: "2. Can I pass a multi-dimensional array to a function ?"

Yes, sort of when using my plug-ins, but I advise you not to go there unless you are adventurous or experienced.

Quote: "As I know, all DIM arrays are global"

Arrays are global unless you specify otherwise


Reek
13
Years of Service
User Offline
Joined: 21st Aug 2011
Location:
Posted: 23rd Aug 2011 14:21
Thanks Guys!
I Appreciate all your help
Burning Feet Man
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 24th Aug 2011 13:31
Quote: "Quote: "2. Can I pass a multi-dimensional array to a function ?"
Yes, sort of when using my plug-ins, but I advise you not to go there unless you are adventurous or experienced."


I'm one happy coder after figuring out array pointers, and you will too! They're so awesome. But IanM is right, figure out the basics first.

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia

Login to post a reply

Server time is: 2024-11-22 17:14:46
Your offset time is: 2024-11-22 17:14:46