|
Re: In need of array help! [message #61300 is a reply to message #61299] |
Fri, 11 July 2008 10:40   |
Paul Van Delst[1]
Messages: 1157 Registered: April 2002
|
Senior Member |
|
|
.Pink wrote:
> Hi folks, I'm new to IDL and I'm having a bit of trouble with array
> manipulation.
>
> I have a program that encounters data sets of varying sizes, and I
> need to store the information into an array contained in an object.
>
> I've tried using the array resizing techniques found in
> http://www.dfanning.com/code_tips/nullarray.html, but no matter what I
> to, I am unable to actually change the size!
>
> Any suggestions would be very very very helpful!
>
> Thanks,
> Aaron
> -------------
> struct = {PermResults, $
> SliceNum: 0.0, $
> roiValues: fltarr(100000), $ ;100000 is far more than I
> need, but still a terrible way to do it.
> area: 0.0, $
> perimeter: 0.0, $
> pxlcount: 0L}
> ---------------------
You should read up on the differences between named and unnamed structures. Apart from
that, two things spring to mind:
1) Pointers:
struct = {PermResults, $
SliceNum: 0.0, $
roiValues: ptr_new(/allocate_heap), $
area: 0.0, $
perimeter: 0.0, $
pxlcount: 0L}
you can then simply do
*struct.roiValues = ...data...
as required to "create" the data entry to what ever size you want.
2) Use CREATE_STRUCT() to create your structure on the fly. It can be a bit of a pita to
do that though - I've only found it useful when I do the same thing over and over again
(e.g. reading netCDF files) so that I can stick all the mucking about in a procedure. And
I don't think you can do it for named structures that you will add stuff to after
creation.... but I'm not sure.
cheers,
paulv
|
|
|
Re: In need of array help! [message #61368 is a reply to message #61299] |
Mon, 14 July 2008 08:10  |
humanumbrella
Messages: 52 Registered: June 2008
|
Member |
|
|
On Jul 11, 1:48 pm, ".Pink" <aaron.p...@gmail.com> wrote:
> Wow, Thank you so much paulv! I definitely appreciate the help!
Make sure to clean up your pointers afterwards.
Also - I find it interesting that you originally posted at 1:11 on
July 11.
Lot of 1's up there.
|
|
|