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 / A stupid question about arrays

Author
Message
tayete
21
Years of Service
User Offline
Joined: 20th Nov 2002
Location:
Posted: 6th Apr 2004 18:55
How on earth can I add (or substract) a complete row of items to an array? I cannot find it in the manual, the examples or in this forum.

I mean, I have
DIM(x,y) but now I want to have an array of (x+10,y+5). How do I add the 10 and 5?
This is turning me nuts.

Thanks a lot.

__________________________
http://www.tayete.com
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 6th Apr 2004 19:06
You can't do that safely - not until update 6. Then you'll be able to resize an array without losing the current contents

*** 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
Clownpaint
20
Years of Service
User Offline
Joined: 23rd Dec 2003
Location: London, England
Posted: 6th Apr 2004 19:13 Edited at: 6th Apr 2004 19:16
you could do

DIM x(1,2)
x(1,1)=10
x(1,2)=10

x(1,1)=x(1,1)+10
x(1,2)=x(1,2)+5


i hope thats what you want... i just finished arrays in the manual. Actually ive just realised thats not what you want! but i hope it helps anyway lol.
tayete
21
Years of Service
User Offline
Joined: 20th Nov 2002
Location:
Posted: 6th Apr 2004 19:15
But...but...this is...outrageous! I cannot wait months

__________________________
http://www.tayete.com
tayete
21
Years of Service
User Offline
Joined: 20th Nov 2002
Location:
Posted: 6th Apr 2004 19:19
No ClownPaint, what I pretend is to add 10 new elements to the array, not just adding a variable or constant to an element. It involves realocating memory and such, so that's why maybe it hasn't implemented yet, though any modern language can take advantage of it.

Anyone knows any other way to make this? Pointers?

__________________________
http://www.tayete.com
Clownpaint
20
Years of Service
User Offline
Joined: 23rd Dec 2003
Location: London, England
Posted: 6th Apr 2004 19:21
k, i just got it all wrong then realised after i posted lol.
andrew11
21
Years of Service
User Offline
Joined: 23rd Feb 2003
Location: United States
Posted: 6th Apr 2004 20:45
I use Array insert at bottom. It works, but only for one dimensional arrays. Its best to avoid having to resize arrays.

You could Undim the array, then Dim it again bigger. Then transfer the data from one to the other using a temporary array.

"All programmers are playwrites and all computers are lousy actors" -Anon
tayete
21
Years of Service
User Offline
Joined: 20th Nov 2002
Location:
Posted: 6th Apr 2004 20:57
Great Andrew...that could work. Thanks a lot, I'll try it.

__________________________
http://www.tayete.com
Emperor Baal
20
Years of Service
User Offline
Joined: 1st Dec 2003
Location: The Netherlands - Oudenbosch
Posted: 6th Apr 2004 22:25
Or just dim an array that is big enough, and use the elements when you need them

Quote: "
UPDATED

Amd 2800+ 1024mb pc3200 A7N8X - Deluxe Ati Radeon 9800PRO 256mb
"
tayete
21
Years of Service
User Offline
Joined: 20th Nov 2002
Location:
Posted: 7th Apr 2004 11:40
Thanks Emperor, that could work too. Let's see if my *wonderful* system can maintain that. The fact is that I am creating a DIM of TYPE that has several variables in it, and it may be too large. But I'll try that too!

__________________________
http://www.tayete.com

Login to post a reply

Server time is: 2024-09-22 04:27:13
Your offset time is: 2024-09-22 04:27:13