|
|
Re: Problem with INFO definition [message #45174 is a reply to message #45173] |
Tue, 16 August 2005 09:42  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Pravesh writes:
> Thats right! U have spoken about it in your book.
> Thanks for the info...
> Do u think that exporting formatted data to excel sheets is a good
> idea? I have tried it and it does look ok..
No, I think exporting data to an Excel spreadsheet is
a sacrilege. :-)
> again, how do i append data
> to an existing file ?
Open the file with OPENU.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
Re: Problem with INFO definition [message #45175 is a reply to message #45174] |
Tue, 16 August 2005 09:05  |
pravesh.subramanian
Messages: 21 Registered: August 2005
|
Junior Member |
|
|
Hi David,
Thats right! U have spoken about it in your book.
Thanks for the info...
Do u think that exporting formatted data to excel sheets is a good
idea? I have tried it and it does look ok.. again, how do i append data
to an existing file ?
Pravesh
|
|
|
Re: Problem with INFO definition [message #45176 is a reply to message #45175] |
Tue, 16 August 2005 08:57  |
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/
|
|
|