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.

Author
Message
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 11th Apr 2009 01:33
Hi, I have an array, it has two dimensions. Eg Myarray(17,3)
however, i want to empty or delete one of the indexes , so it would be Myarray(16,3) however, the data could be anywhere in the array. How would i delete one part of the array? sorry if my meaning isnt clear
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 11th Apr 2009 04:16
I'm not completely sure, but I believe you could just DIM the array again with your new dimensions? Someone can correct me if I'm wrong.

So,

DIM Myarray(16,3)

<---Spell casting battle game!
feiting shadow
18
Years of Service
User Offline
Joined: 12th Sep 2006
Location:
Posted: 11th Apr 2009 10:53
for good coding, sixty squares is right, (after using Undim, which I just looked up)... lest you already know how to use vectors, then try the "Array Delete Element" command and related, with examples in Core Commands. Along with insert (at top/bottom) and a wealth of neat little vector tricks (referring to C++ STD LIB style vectors, not 3D ones)

And by good coding, I mean don't use that if you don't have to. DBPro may be well-coded, but if this was C, it'd be asking for a memory leak (lest you have clean code)

Signed
------
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 11th Apr 2009 16:22
Yeah sorry, i meant i wanted to keep all the data apart from one little bit
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 11th Apr 2009 23:34
So you want to reduce one of the dimensions of your array?

If that's the case, just use a DIM command with the new values, ie if you have an array(17,3) and you want an array(16,3) then 'DIM array(16,3).

That will remove the last set of values (ie, the 17 column). If that's not the one you want to lose your values from, then you'll need to shuffle everything down manually.

eg, if you want to get rid of column 15, then copy everything from column 16 to 15, then everything from column 17 to 16, then reduce the array size.

Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 11th Apr 2009 23:41
Quote: ""Array Delete Element" command and related"


Do those commands work on multi-dimensional arrays?

<---Spell casting battle game!
feiting shadow
18
Years of Service
User Offline
Joined: 12th Sep 2006
Location:
Posted: 12th Apr 2009 01:06 Edited at: 12th Apr 2009 01:14
That is a good question, I think we're in the same boat on that. I'm gonna test it right now... will edit in a minute with results.
(poke- you can do the same... lol, I'd bet nobody here knows that one, except IanN... for norris that is, chuck's parallel coder-twin)

edit: all that coding and I just get this...
"Runtime Error 55 - Array specified must be a single dimension array for this type of command at line 11"

So that should give us the answer... now to do that darknoobpro project I said I'd do...

Signed
------
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 12th Apr 2009 19:19
Thanks IanM, thats exactly what i need
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 12th Apr 2009 19:49 Edited at: 12th Apr 2009 20:09
hmmm, does it always delete the last column, it seems to be deleting the first

Edit: hmm, fixed it, mustve been that one time. Fixed it it works, although im sure it shouldnt work, it does so im going to leave it, thanks alot guys
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 14th Apr 2009 21:45 Edited at: 14th Apr 2009 21:47
Hey, I have another questions about arrays, say i have a multi dimensional array again, such as myarray(20,20)

if i wanted all 20 of the array to be 1 could i put
myarray(1)=1

or would i have to put
myarray(1,1)=1
myarray(1,2)=1

then again i could use a for next loop if i cant use the first example

Edit
Ah nevermind, i figured it out

Omricon W.I.P
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 16th Apr 2009 16:53
I always try to avoid multi-dimensional arrays when you're going to need to resize them and such, because they don't like having commands like ARRAY DELETE ELEMENT used on them. Instead, I use an array with a User-Defined Type (http://forum.thegamecreators.com/?m=forum_view&t=110324&b=7)



Login to post a reply

Server time is: 2024-11-25 08:27:39
Your offset time is: 2024-11-25 08:27:39