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

Home » Public Forums » archive » Re: Keywords/Parameters and Common Blocks
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: Keywords/Parameters and Common Blocks [message #36908 is a reply to message #36847] Tue, 04 November 2003 02:56 Go to previous message
Nuno Oliveira is currently offline  Nuno Oliveira
Messages: 75
Registered: October 2003
Member
Thank you, David. I'm already making changes in my programs passing the
widget variables to the value of the widget base.



Indeed, I'm trying to build a widget application for medical purposes, but I
'm freshman in IDL. So I'm reading the thousands of pages of the tutorials,
looking at yours and other sites e looking for information here, and
sometimes talking with RSI.



And sometimes happen things just like this. I started to work with widget
programs and immediately found that I needed to pass the variables to the
event routine, so I looked in the tutorials and found that I could do that
with common blocks. And unfortunately I thought the question was solved,
till I noticed that my programs were tremendously confused.



So I hope I don't bore you too much in the future, but I'm getting the idea
that this group is very useful to me, because some things are not too
obvious in the tutorials (and I still didn't touch the Objects)



Cordially,



Nuno.



"David Fanning" <david@dfanning.com> wrote in message
news:MPG.1a0c4f6649abcabc98972a@news.frii.com...
> Nuno Oliveira writes:
>
>
> I get the impression here that you are writing widget
> programs. If so, you do NOT want to be using COMMON blocks. :-)
> Use an "info" or "state" structure instead. See any widget
> program on my web page for an example of how this is done.
>
> Typically, if you want to collect keywords for routines,
> you store them in your info structure so they can be used:
>
> PRO MyProgram, Color=color, Linestyle=linestyle
>
> IF N_Elements(color) EQ 0 THEN color = 'red'
> IF N_Elements(linestyle) EQ 0 THEN linestyle = 1
>
> info = { color:color, linestyle:linestyle }
> Widget_Control, tlb, Set_UValue=info
>
> etc.
> END
>
> Then, you can use them in an event handler:
>
> PRO MyProgramEvents, event
> Widget_Control, event.top, Get_UValue=info
> MYPLOT, findgen(11), Color=info.color, LineStyle=info.linestyle
> END
>
> Sometimes you want to collect "extra" keywords, or keywords
> that you might want to use, but don't want to take the time
> to define. Then you might use a pointer to store these "extra"
> keywords:
>
> PRO MyProgram, _Extra=extra
>
> IF N_Elements(extra) EQ 0 THEN $
> extra = Ptr_New(/Allocate_Heap) ELSE $
> extra = Ptr_New(extra)
>
> info = { extra=extra}
> Widget_Control, tlb, Set_UValue=info
>
> etc.
> END
>
> Then, use them like this:
>
> PRO MyProgramEvents, event
> Widget_Control, event.top, Get_UValue=info
> MYPLOT, findgen(11), _Extra=*info.extra
> END
>
> Just be sure you free your pointers in the CLEANUP procedure
> you will write for your widget program. :-)
>
> Cheers,
>
> David
>
>
>
> --
> David W. Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Phone: 970-221-0438, E-mail: david@dfanning.com
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
> Toll-Free IDL Book Orders: 1-888-461-0155
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: vector t-test?
Next Topic: Interpolation problem

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

Current Time: Sat Oct 18 02:38:51 PDT 2025

Total time taken to generate the page: 0.31854 seconds