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 / Problem with variables

Author
Message
Numisi
13
Years of Service
User Offline
Joined: 27th Jul 2012
Location:
Posted: 10th Dec 2012 10:52
I know it may look simple to you, but I don't know how to manage this problem...
I want to create an array for every cycle of a for-next loop, but I can't figure out how.
I mean something like this:

for i=1 to 10
dim {i as the name of the array}(10, 2)
next i

Can you help me? Thanks to everyone!
Sergey K
22
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 10th Dec 2012 16:00 Edited at: 10th Dec 2012 16:02


didnt tested, but it supposed to work.

its called Dynamic Arrays.

Advanced Updater for your games!
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 10th Dec 2012 17:04 Edited at: 10th Dec 2012 17:05
With 1-dimensional arrays it's cleaner to use the command array insert at bottom:



With 2-dimensional arrays you'll have to get dirty and use work-arounds, such as re-defining the array, even if it already exists (basically what Sergey is doing).

TheComet

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 10th Dec 2012 20:19
What Sergey's code does is redefine the array size. But to have a unique array created... not possible because there's no way to name an array via shall we say strings. But what you could do is predefine all the arrays then set them up via a temp array that runs through the for and next loop.

Though this really depends on what your doing. If you give us alittle more information then we can help more accurately.

Login to post a reply

Server time is: 2026-07-07 07:34:00
Your offset time is: 2026-07-07 07:34:00