Re: Changing elements in structures [message #18301] |
Thu, 16 December 1999 00:00 |
m218003
Messages: 56 Registered: August 1999
|
Member |
|
|
In article <3857A92E.1DB64CF0@ssec.wisc.edu>,
Liam Gumley <Liam.Gumley@ssec.wisc.edu> writes:
>
> ;- Define the structure
> info = {filename:'', data_ptr:ptr_new(1.0)}
>
> ;- After you've read the data, store it in the structure
> data = dist(256)
> *info.data_ptr = data
>
> ;- Use the data
> data = *info.data_ptr
> tvscl, data
>
> Cheers,
> Liam.
>
And then you loose your memory ;-)
Don't forget to call PTR_FREE,info.data_ptr at some point. Oh! I forgot,
with IDL 5.3 you can now use .RESET_SESSION ...
Martin
--
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[[ Dr. Martin Schultz Max-Planck-Institut fuer Meteorologie [[
[[ Bundesstr. 55, 20146 Hamburg [[
[[ phone: +49 40 41173-308 [[
[[ fax: +49 40 41173-298 [[
[[ martin.schultz@dkrz.de [[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
|
|
|
Re: Changing elements in structures [message #18315 is a reply to message #18301] |
Wed, 15 December 1999 00:00  |
Liam Gumley
Messages: 473 Registered: November 1994
|
Senior Member |
|
|
Alvaro wrote:
> I'm making a program that is a HDF viewer. My problem is how to pass
> information between widgets.
> I use a structure to pass the information but the problem is that at start I
> don't know the size of the data, which will be read later from a file. I use
> somethisg like this:
>
> info={filename:"", $
> data:IntArr(1,1) }
>
> I use IntAr(1,1) because I don't the size until I open the filename
> Can I change the size and also the type (Int to Float or Byte) of the tag
> "data" of the structure?
You cannot change the size of type of a variable in a structure without
re-creating the structure.
> Have you got any idea to do this, perhaps using pointers?
;- Define the structure
info = {filename:'', data_ptr:ptr_new(1.0)}
;- After you've read the data, store it in the structure
data = dist(256)
*info.data_ptr = data
;- Use the data
data = *info.data_ptr
tvscl, data
Cheers,
Liam.
--
Liam E. Gumley
Space Science and Engineering Center, UW-Madison
http://cimss.ssec.wisc.edu/~gumley
|
|
|
Re: Changing elements in structures [message #18324 is a reply to message #18315] |
Wed, 15 December 1999 00:00  |
Karri Kaksonen
Messages: 27 Registered: October 1999
|
Junior Member |
|
|
Alvaro,
Alvaro wrote:
> I use a structure to pass the information but the problem is that at start I
> don't know the size of the data, which will be read later from a file. I use
> somethisg like this:
>
> info={filename:"", $
> data:IntArr(1,1) }
Pointers work well for space holders.
info={filename:"", $
data: ptr_new()
}
Later you can fill in any data like this:
if valid_ptr(info.data) then ptr_free, info.data
info.data = ptr_new(intarr(1,1))
--
Regards,
Karri Kaksonen
|
|
|