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 / Experiencing array difficulties.

Author
Message
Soy Cocktail
20
Years of Service
User Offline
Joined: 23rd Dec 2003
Location:
Posted: 14th Oct 2004 13:45
I am currently working on a console function. It is simmilar to the ones in first person shooters that drop down from the top of the screen when you push the button to the left of the 1, the "`".
I have it working fine for now, but I am having problems getting it to extend the array. If I use the dim command on the array it deletes the vaules that were in the array. I currently just dim the array to 100 so I can have 100 things in it. After you enter over 100 things the program will crash. It is also not optimized this way.

Basically my question is: how can I extend an array. I have tried using the "ARRAY INSERT AT BOTTOM" command but couldnt get it to work. If source is needed I can post it.

Aku Soku Zan
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 14th Oct 2004 17:45
the syntax is:

ARRAY INSERT AT BOTTOM(MyArray())

You should then be able to access the element you just added like this...

MyArray() = "Object 101"

It can also be accessed by finding the last element number...

GET ARRAY COUNT(MyArray())

Don't forget to subtract 1, as arrays start at 0.

Hope this helps.

BatVink
http://biglaugh.co.uk/catalog AMD 3000+ Barton, 512Mb Ram, 120 Gig Drive space, GeForce 5200 FX 128 Mb, Asus A7N8X Mobo.
Terms & Conditions apply
100% Pure Dave
20
Years of Service
User Offline
Joined: 10th Mar 2004
Location: Perth, Australia
Posted: 15th Oct 2004 14:59
An alternative method is to keep the array at 100 or whatever size u need and use a routine to shift the elements 'up' in the list effectively wiping out the oldest member of the array and just adding to the last member the new info:



ok that creates the array now to shift the elements you would do something like this:



and that will shift the contents of the array and then replace the last entry with new info.

thats just one way to do it

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 17th Oct 2004 22:13
@Johnny,

Are you using DBC or DBPro - it sounds like DBC. If it is, then you need to use Daves method ... otherwise, can you give us a little code, and the error message you are getting?

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk

Login to post a reply

Server time is: 2024-11-27 13:06:22
Your offset time is: 2024-11-27 13:06:22