widget [message #77816] |
Fri, 07 October 2011 11:42 |
Marco Otto
Messages: 2 Registered: October 2011
|
Junior Member |
|
|
Hi
I am new to widget programming in IDL :-(
maybe someone can tell me how to realise the second step:
1. read a .sav file
2. if there are more than one variable stored then give me a list of
variables (here comes the widget - hence the hard part for me) where I
can interactively select the variable I want to be read into IDL
3. rename the variable
That's all! But somehow I don't get it - seems a bit over complicated
in IDL - but the problem is definitely sitting in front of the
screen ;-)
Here is what I have so far
pro rename_input_to_lu_mask,fname,lu_msk
restore,fname
; I don't know the exact name of the variable so I have to find them
from the main level
level = Scope_Level()
arg = Scope_VarName(Level = Level)
; find all known/defined variables at the main level
idx = where(arg ne str_equiv('FNAME') and arg ne str_equiv('LEVEL')
and arg ne str_equiv('LU_MSK') and arg
ne str_equiv('ARG') and arg ne str_equiv('IDX')and
arg ne str_equiv('VERBOSE')and arg ne
str_equiv('CNT')and arg ne str_equiv('tlb') and
arg ne str_equiv('wid') and arg ne str_equiv('base')
and arg ne str_equiv('EVENT'),cnt )
; the easy case: the one not found at main level are the restored
ones - that works perfectly for me
if cnt eq 1 then lu_msk = Scope_VarFetch(arg[idx], LEVEL=LEVEL)
; the not so easy (and not working so far) case
if cnt gt 1 then begin
print, 'There is more then one variable stored in the sav-file!'
base=WIDGET_BASE(/COLUMN,title='Select variable!',xsize=300,
ysize=250)
wid= WIDGET_LIST(base,VALUE= str_equiv(arg[idx]))
; the following is just a rough guess! I already know that's not
working but with one or two more lines of the
; right code it should work shouldn't it ? :-)
WIDGET_CONTROL,wid, /REALIZE,/SHOW, GET_VALUE=wid,FUNC_GET_VALUE =
'Scope_VarFetch()',/SENSITIVE
endif
end
any help will be appreciated.
Regards
Marco Otto
|
|
|