Re: passing parameters from base to base [message #32987 is a reply to message #32984] |
Fri, 22 November 2002 07:37   |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
Gert wrote:
> Hi,
>
> I've been trying to figure this one out for a while. I have 2 bases. If in
> Mainbase the button Set is pushed, a second base SetParams is called. Stuff
> happens there and the idea is that if SetParams is killed, a series of
> numbers go back to Mainbase. Now how can you write this neatly, so that the
> code for the SetParams can easily be used in other progs?
> These are my thoughts:
> I could pass a pointer to SetParams that keeps the desired data, but how
> does Mainbase knows that
> SetParams is killed and that it needs to update its fields?
> I looked at the examples for compound widgets (e.g. cw_defroi) and these do
> the trick but they do not use xmanager. Is this the only way.
>
> thx for any help,
>
> Gert
>
>
>
>
Dear Gert
this is a small example how to exchange data.
The trick is to give all the widget functions a UNAME then you can get
access to each of them by widget_info at every program state.
You have only to know the top level base id.
If you use uname you can save and restore data from uvalue of each
element. This is pretty fine.
If you like to have more examples you can have a look at wid1 to wid5
in the widget explaination at
http://www.fz-juelich.de/vislab/software/idl_samples/IDL-Bei spielsammlung.html
These are the examples from our idl lessons at FZ Juelich.
PRO small_widget_event,event
name=WIDGET_INFO(event.id,/UNAME)
PRINT,name
WIDGET_CONTROL,event.top,get_uvalue=data
CASE name OF
'QUIT': WIDGET_CONTROL,event.top,/destroy
'START': BEGIN
WIDGET_CONTROL,get_value=wid,$
WIDGET_INFO(event.top,find_by_uname='DRAW')
WSET,wid
TVSCL,*data
END
'SLIDER' :BEGIN
WIDGET_CONTROL,event.id,get_value=value
TVSCL,*data<value
END
ELSE:
ENDCASE
END
PRO small_widget
data=PTR_NEW(DIST(256))
base=WIDGET_BASE(col=2,title='variables between widgets',$
uvalue=data)
id=WIDGET_BUTTON(base,value='START',uname='START')
id=WIDGET_BUTTON(base,value='QUIT',uname='QUIT')
base2=WIDGET_BASE(base,row=1, $
title='variables between widgets')
id=WIDGET_DRAW(base2,retain=2,xsize=256,ysize=256,$
uname='DRAW')
id=WIDGET_SLIDER(base2,/vertical,min=1,$
max=255,value=255,uname='SLIDER')
WIDGET_CONTROL,/realize,base
XMANAGER,'small_widget',base
PTR_FREE,data
END
--
Reimar Bauer
Institut fuer Stratosphaerische Chemie (ICG-I)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
------------------------------------------------------------ -------
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html
============================================================ =======
|
|
|