Phil Williams <williams@irc.chmcc.org> wrote:
> I'm developing several widget based apps and have a question concerning
> the use of structures and common blocks.
> I have found both of these invaluable, but the problem comes when I want
> to add a variable to a common block or structure. When I try to
> recompile the .pro file idl won't let me. Is there another way to do
> this other than quitting IDL and starting it over?
> Along this theme, is there a way to "uncompile" a procedure or function
> so that IDL forgets about it?
> Thanks in advance,
> --
> /*********************************************************** ********/
> Phil Williams, Ph.D.
> Research Instructor
> Children's Hospital Medical Center "One man gathers what
> Imaging Research Center another man spills..."
> 3333 Burnet Ave. -The Grateful Dead
> Cincinnati, OH 45229
> email: williams@irc.chmcc.org
> URL: http://scuttle.chmcc.org/~williams/
> /*********************************************************** ********/
Well,
I've encoutered the same problem. My solution:
Use a (fixed number of) anonymus structures in the common blocks, e.g.
for keeping the widget ID's. So when you decide to add a widget, you
can add a field in the (anonymus) structure without restarting IDL.
As far as I know it isn't possible to change the size of a common
block, so you have to plan the number of variables in advance (e.g.
one (anonymus structure) for Widget ID's, one for return values, one
for status values etc.
some excerpts from one of my widget-app's:
; the first (sub) routine in the file, defining the common block
pro sXRDSQLPR_INIT_READ, nrlines
COMMON XRDSQLPR_BLOCK, state, res, exitcode, linesread, LinesToRead, $
LineBuffer, maand_code, $
last_baannum, baancount, jaar, beschr
.
.
.
; the main function
function XRDSQLPR, GROUP=Group, RESULT=result,
BESCHRIJVING=beschrijving, STARTPATH=startpath
COMMON XRDSQLPR_BLOCK
wid = $
{main:-1L,Inlezen:-1L,afsluiten:-1L,bestand:-1L,omvang:-1L,j aar:-1L,bestandjaar:-1L,$
baanvakcount:-1L,actie:-1L,regelselectie:-1L,regelcount:-1L, $
knoppen:-1L}
IF N_ELEMENTS(Group) EQ 0 THEN GROUP=0
junk = { CW_PDMENU_S, flags:0, name:'' }
MAIN = WIDGET_BASE(GROUP_LEADER=Group, $
COLUMN=1, $
SPACE=5, $
XPAD=5, $
YPAD=5, $
MAP=1, $
TITLE='Lees SQL printbestand', $
UVALUE='MAIN')
wid.main = MAIN
wid.inlezen = WIDGET_BASE(MAIN, $
COLUMN=1, $
FRAME=1, $
MAP=1, $
TITLE='displaybase', $
UVALUE='Inlezen')
.
.
WIDGET_CONTROL, MAIN, /REALIZE
state= {wid:wid, path:startpath,filename:'',filestat:FS, $
filemask:'*.*'}
widget_control, state.wid.regelcount, sensitive =0
XMANAGER, 'XRDSQLPR', MAIN
result = res
return , exitcode
end
I hope these suggestions will help you in some way,
Cees van Nieuwenhuize
e-mail: C.v.Nieuwenhuize@net.HCC.nl
Gouda, Netherlands
|