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

Home » Public Forums » archive » Re: working with restored values
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: working with restored values [message #11131] Mon, 02 March 1998 00:00
Cathy Campo is currently offline  Cathy Campo
Messages: 7
Registered: October 1997
Junior Member
> Cathy Campo (campo@gav.gat.com) writes:
>
> I am restoring a save file (i do not know the names of the
> variables in advance or their data type), and displaying some of the
> variable names to the user to choose from in a droplist.
>
> restore, 'junk.sav'
> help, output=tmpstr
> varlist = strarr(5)
> varlist = tmpstr(0:4)
> widget_control, droplist, set_value=varlist
>
> i would like to save the actual values of the variables in a
> array of pointers. (have this be the uvalue of the droplist?)
> but how would i do this?
>
> later i would be using the array of pointers in the event
> loop of the droplist to do calculations with the value chosen.

David Fanning wrote:

> I would try something like this:
>
> varValues = FltArr(5)
> For j=0,4 DO ok = Execute('varValues[j] = ' + varlist[j])
> Widget_Control, droplist, Set_Value=varlist, Set_UValue=varValues

David's suggestion would be good if I knew that all of the
variables were of data type 'float', but I don't. So using his
advice and my idea of pointers, I am able to do this:

restore, 'junk.sav'
help, output=tmpstr
varlist = strarr(5)
varlist = tmpstr[0:4]
widget_control, droplist, set_value=varlist
; store varlist in uvalue of base widget
ptr = ptrarr(5, /allocate_heap)
for i = 0, 4 do ok = execute('*ptr[i] = ' + varlist[i])
widget_control, droplist, set_uvalue=ptr

in the event loop i am able to do this:

; get back varlist from uvalue of base widget
widget_control, droplist, get_uvalue=ptr
nvars = n_elements(varlist)
for i = 0, nvars-1 do begin
print, varlist[i]
help, *ptr[i]
endfor



Cathy
Re: working with restored values [message #11132 is a reply to message #11131] Mon, 02 March 1998 00:00 Go to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Cathy Campo (campo@gav.gat.com) writes:

> I am restoring a large save file, and displaying some of the
> variable names to the user to choose from in a droplist.
>
> restore, 'junk.sav'
> help, output=tmpstr
> varlist = strarr(5)
> varlist = tmpstr(0:4)
> widget_control, droplist, set_value=varlist
>
> i would like to save the actual values of the variables in a pointer
> array or structure. (have this be the uvalue of the droplist?)
> but how would i do this?
>
> later i would be using the pointer array or structure in the event
> loop of the droplist to do calculations with the value chosen.

I presume from this that you do NOT know the names of the
variables in advance. I would try something like this:

varValues = FltArr(5)
For j=0,4 DO ok = Execute('varValues[j] = ' + varlist[j])
Widget_Control, droplist, Set_Value=varlist, Set_UValue=varValues

Cheers,

David
-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438
Coyote's Guide to IDL Programming: http://www.dfanning.com/
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: mean and sdev
Next Topic: working with restored values

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

Current Time: Wed Oct 08 11:51:28 PDT 2025

Total time taken to generate the page: 0.00610 seconds