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 / creating arrays on the fly

Author
Message
simonuk74
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location:
Posted: 23rd Mar 2003 03:20
I want to be able to enter the contents of an array, and adjusting the size accordingly, I`ve tried using the `array insert at top/bottom` commands, but it`s not working how I expected.

whats happening is the array is filling with the last information I enter.

a=0
dim test$(0)
print "enter a max of 10 strings to create an array with"
print "enter nothing to finish"
do
inc a
array insert at top test$(0)
input "name",n$
if len(n$)
simonuk74
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location:
Posted: 23rd Mar 2003 03:30
ok, just realised that only half my message got sent ???



so theres the code again, slightly altered, - just a few print statments to help me figure out whats happening, but I cant figure it

simonuk74
23
Years of Service
User Offline
Joined: 3rd Nov 2002
Location:
Posted: 23rd Mar 2003 06:06
its working now, just a case of playing wit hthe `a` variable, and adding to the bottom of the array.

the architect
23
Years of Service
User Offline
Joined: 6th Jan 2003
Location: United Kingdom
Posted: 23rd Mar 2003 22:51
Simonuk,

Apparently dynamic arrays are not working properly and will be fixed in later patches. For now I have used fixed array sizes.

MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 23rd Mar 2003 23:55
I've got a linklist plug-in that may be of use...

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
Galiem
23
Years of Service
User Offline
Joined: 27th Nov 2002
Location: United States
Posted: 24th Mar 2003 07:31
Another option is to use a memblock, and have the array dimensions be controled by values in the memblock.

For example, if your array is meant to store information regarding each individual tile on a matrix, a memblock could store the values representing how the matrix is prepared, and then the array created by assigning a variable to equal the value in each repspective memblock position, and then use the variables to specify array size.

Xsegment = MEMBLOCK BYTE 1,1
Zsegment = MEMBLOCK BYTE 1,2

DIM Segments(Xsegment, Zsegment)

In this way, the array dimensions will always be equal to whatever the matrix X and Z segements were stored as.

Hope I help some, but I'm sort of an advanced newbie myself, when it comes to DBPro... I am writing some extensive code, but have a long ways to go before I will be testing it... Variables CAN be used to specify array dimensions in DBPro, right? I hope they can anyway lol

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 24th Mar 2003 15:13
Although most of the array commands are not working, ARRAY INSERT AT BOTTOM works fine.
MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 24th Mar 2003 15:36
The choice, as they say, is yours...

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!

Login to post a reply

Server time is: 2026-07-10 20:57:22
Your offset time is: 2026-07-10 20:57:22