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

Home » Public Forums » archive » Re: Returning result from a widget program.
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Returning result from a widget program. [message #12202 is a reply to message #12187] Thu, 09 July 1998 00:00 Go to previous message
David Foster is currently offline  David Foster
Messages: 341
Registered: January 1996
Senior Member
Imanol Echave wrote:
>
> Hi people:
>
> I'm writting an IDL function that works with widgets. The user calls an IDL
> function that shows an widget interface to input data. When the user pushes the
> "OK" button the function has to return a result that depends on the input data.
> My problem is where to store this result to return it. I can't use the UVALUE of
> the widgets because when I want to return the result the widgets are destroyed.
> Any advice?

Hi Imanol -

I think the best thing you can do is to first create a "state info"
structure that contains contains useful information about your
widget, including status and especially the "result" from your
user input. Then create a pointer to this structure:

statePtr = ptr_new( { status: 0, status_msg: '', result: 0 } )

Then store this pointer in the UVALUE of the TLB (top-level-base) of
your widget heirarchy, right before calling XMANAGER:

widget_control, base, set_uvalue=statePtr

XMANAGER, 'name', base

(Be SURE not to use /NO_BLOCK here! You want the function to wait
until you're done.)

Then at the beginning of your event handler you get this pointer
back from the UVALUE:

widget_control, event.top, get_uvalue=statePtr

and you can access all of your structure elements within the event
handler like:

temp = (*statePtr).result

Then, at the end of your function, to return the result(s) of the
function you add the next lines *after* the XMANAGER call:

return_value = (*statePtr).result
ptr_free, statePtr ; Be SURE to free memory!
return, return_value
END

Of course, if you need to return more items, you can make a new
structure from some of the fields of (*statePtr), and then return
that instead. The point is that you can use this method to return
whatever you like. The key is that I'm assuming that this will be
a "modal" widget, which will wait until the user presses "Ok"
before returning (keyword /NO_BLOCK is not used in XMANAGER call).

Hope this helps.

Dave

--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
foster@bial1.ucsd.edu Department of Psychiatry
(619) 622-5892 8950 Via La Jolla Drive, Suite 2240
La Jolla, CA 92037
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: CALL EXTERNAL FOR PASSING STRING ARRAYS FROM FORTRAN UNDER OPENVMS
Next Topic: Re: Creating Variables in Programs

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

Current Time: Fri Oct 10 22:39:56 PDT 2025

Total time taken to generate the page: 1.19912 seconds