comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Problem with INFO definition
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Problem with INFO definition [message #45176 is a reply to message #45175] Tue, 16 August 2005 08:57 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
pravesh.subramanian@gmail.com writes:

> I am a big fan of David's book and I like the way Info structure has
> been used. I use the same method to handle data to be passed around.
> In one of my Event handler proc, I am returned a 1-d array which I
> would like to put in Info.
> Since I do not know the size of this array, how is it possible to
> define this 1-d array in the INFO structure in the Widget Def. Module?
>
> currently, I do something like this...
>
> 1-d = bytarr(32000)
> ...
>
> info = { $
> ......
> 1-d: 1-d $
> }
>
> I really donno what size this array could take (anything between 0 and
> 32000).
> Is there a way to define this element in the event handler and not the
> WDM? What if the size of this array is not fixed (say the 32000 factor
> is not available).

Anytime you have information in the info or state structure
and you don't know how big it is, or the size might be changing,
you use a pointer to store it. This doesn't change the size
of the info structure, and allows you to redefine your data
at will.

info = { $
....
data: Ptr_New(), $
}

When you go to fill it up:

IF Ptr_Valid(info.data) THEN $
*info.data = data ELSE info.data = Ptr_New(data)

Of course, you need to free the pointer in the CLEANUP
method of the widget program, so you don't leak memory
when your widget program is destroyed.

Cheers,

David

P.S. I thought this was explained pretty well in that
darn book. :-)
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Install ENVI/IDL on cygwin
Next Topic: Re: Como unir la interfaz garfica con los procedimientos

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 16:12:57 PDT 2025

Total time taken to generate the page: 0.16118 seconds