Jump to content
Sign in to follow this  
Drinker

Command - array resize

Recommended Posts

There's a big problem...it doesn't resize only the selected array, but also all arrays that are equal to that array. Example:

_Array1=[2,3,4,5]

_Array2=_Array1

_Array1 resize 2

The result is:

_Array1=[2,3]

_Array2=[2,3] -> why the hell resizes both arrays??

can anybody show how to workaroud this in a simple way?

thx

Share this post


Link to post
Share on other sites

Edit: Denoir solved it smile_o.gif

RED

Share this post


Link to post
Share on other sites
Guest
There's a big problem...it doesn't resize only the selected array, but also all arrays that are equal to that array. Example:

_Array1=[2,3,4,5]

_Array2=_Array1

_Array1 resize 2

The result is:

_Array1=[2,3]

_Array2=[2,3] -> why the hell resizes both arrays??

can anybody show how to workaroud this in a simple way?

thx

Arrays are passed by reference. You have to use the unary operator (+).

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Array1=[2,3,4,5]

_Array2=+_Array1

_Array1 resize 2

This only works for one level of arrays. If you have arrays within arrays then you have to do a loop and copy the values over.

Share this post


Link to post
Share on other sites

Thx a lot smile_o.gif

however, i found another way

_Array1=[2,3,4,5]

_Array2=_Array1

_Array2=_Array2+[]

_Array1 resize 2

with +[] the program thinks that the arrays are now different and resizes only the first, i think that this should work also for arrays within arrays

cya smile_o.gif

Share this post


Link to post
Share on other sites
Guest
wow_o.gif  wow_o.gif Thanks a lot! You've just simplified a lot of my scripts that use matrices!  smile_o.gif

Share this post


Link to post
Share on other sites

biggrin_o.gif you never know, there can always be a better trick to workaround

glad to help you smile_o.gif

cya

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×