Re: Help ! [message #14901 is a reply to message #10451] |
Thu, 01 April 1999 00:00   |
Ivan Zimine
Messages: 40 Registered: February 1999
|
Member |
|
|
VU KHAC Tri wrote:
>
> Hi folks,
>
> I write a procedure which reads an image when a button pressed.
>
> pro BTLoad_Event, event
> WIDGET_CONTROL, event.id, GET_UVALUE = info
> fname = DIALOG_PICKFILE(FILE = info.filename, /READ, FILTER = '*.hdr',
> $
> /MUST_EXIST, /FIX_FILTER, PATH = path, /NOCONFIRM)
> IF fname NE "" THEN BEGIN, info.image
> ;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> ENDIF
> end
>
> pro Read_Analyze, File, Image
> ;it reads some data from the file and modifies some fields in Image
> end;
>
> I see that in the Read_Analyze, data is read correctly, but in
> BTLoad_Event, info.image is not modified. Anyone can tell me why ?
>
> Best regards,
> Tri.
Since, info.image is a structure de-reference it is passed to
Read_Analyze by value and not by reference (IDL Programming Techniques
p.207 :-)) which means that when you exit from Read_Analyze, info.image
is not changed.
You can do the following:
IF fname NE "" THEN BEGIN
Read_Analyze, fname, tmp
info.image=tmp
endif
WIDGET_CONTROL, event.top, SET_UVALUE=info
but i think that Read_Analyze would work better if it was a function,
then you could do
info.image=Read_Analyze(fname)
Also look at pointers to pass image data between event handlers...
cheers
--
Ivan Zimine
Dpt. of Radiology (MRI), Geneva University Hospitals
email: ivan.zimine@physics.unige.ch
tel. : (+41 22) 372 70 70
|
|
|