I'm relatively new to IDL, so I'm sure what I want to do is actually quite trivial!
I'm creating a class with a few member variables. Two of these will just be floats, but the third I would like to be an 3-dimensional array with unknown size (well.. actually I know the size of the third dimension to be 12, but that's it!). How do I declare this in the class definition or is it not possible? Maybe I need to work with a non-array data structure..?
Here's my code so far:
pro field__define
void={field, lat_res: 0.0, long_res: 0.0, values: ?!?!?!?!}
return
end
You want to use a pointer, like:
pro field__define
void = { field, lat_res: 0.0, long_res: 0.0, values: ptr_new() }
end
By the way, there is no need for a RETURN
in the definition, execution returns when it hits an END
statement.
This does not actually create a pointer, it just saves space for the pointer. When you want to use the field, you will need to do something like:
self.values = ptr_new(fltarr(3, 4, 5))
Then use the values like:
help, *self.values
Lastly then don't forget to clean up the heap when you are done with array with:
ptr_free, self.values
It might be good to get a book for topics like this, there are a lot of details that following a few examples through can help with.