|
![](/i/fill.gif) |
> Because the array is declared outside of the macro which populates it, to
> facilitate its passing to other macros as a variable, so always returns
> whatever you defined its length to be, regardless if it has been populated
> with that many values.
>
> Pov doesn't support redimensioning, does it?
Yeah, it does support redimensioning, you just redeclare it;
there's a bit of memory overhead is all.
// oversized array sample
#declare MyArray = array [1000];
#declare MyArray[0] = 1;
#declare MyArray[1] = 2;
// resize the array to fit the data
#macro resize_array(ar)
#local c = 0;
#while (defined(ar[c]))
#local c=c+1;
#end
#local new_ar = array[c];
#local c2=0;
#while (c2<c)
#local new_ar[c2]=ar[c2];
#local c2=c2+1;
#end
#declare ar = new_ar;
#end
// some output
#debug concat("Dimension Size = ", str(dimension_size(MyArray,1),0,0),"\n")
resize_array(MyArray)
#debug concat("Dimension Size = ", str(dimension_size(MyArray,1),0,0),"\n")
#error "Stop"
Post a reply to this message
|
![](/i/fill.gif) |