I have a two dimensional parameter array which by default is dynamic and grows according to the number of elements in my parametric object. What I am wondering is how do you get the array to shrink if the object no longer needs as many points e.g. if A = 10 it creates an array of 10 points but if I reduce A to 5 I am still left with a 10 point array?
I am trying to avoid having a parameter array for 100 x 20 = 2000 values when I might only need 5 x 20 = 100 values.
I control the growing and shrinking of all my arrays (I have hundreds across my objects) using the following technique (master script):
!!array name = arrName !!array rows = rowDim dim _arrName for i = 1 to rowDim if i > vardim1(arrName) then _arrName = 0 !!depends on the type of parameter; could be string "" else _arrName = arrName endif next i arrName = _arrName parameters arrName = arrName
This sets the size of the array to a locally declared array and then maps the parameter array to the local array.
It also means you can use the latest array values, before they are updated in the parameter array, by referencing the local array instead (_arrayName). This is the most important feature as it makes the object respond more dynamically.
@Kristian Bursell Thank you ! I did try assigning a local array but it didn't seem to work. Up and running now. I have consolidated your suggestion as my object array values are always rebuilt from scratch while being added to the parameter. Basically I have set the local array to be 1 x 1 and use that to reset the parameter.
!Create local single cell array DIM _arrNull _arrNull = 0.0 arrName = _arrNull PARAMETERS arrName = arrName ... !Add new values to parameter array