[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: widget_control from call_external
David Fanning wrote:
>
> dominic@work.com (dominic@work.com) writes:
>
> > I have a c/c++ programme that is called from within a
> > widget hierachy via call_external.
> >
> > As the computations made take fairly long, I want to update
> > a status bar with a 'Percentage complete' from the C-routine,
> > so the user doesn't get upset and thinks the programme died
> > on him/her.
> >
> > How do I go about that???
>
> Well, this will be difficult unless your can call your
> C program in "chunks", or in some other way interrupt
> it. It might be easier if you just know, in general,
> how long it takes. Then you can set a "kitchen timer"
> sort of progress indicator. As long as the cake is
> baked by the time the timer goes off, no one seems
> to care. :-)
>
> You can see several ways to build such a progress
> indicator here:
>
> http://www.dfanning.com/tips/show_progress.html
I would use alarm() to throw a SIGALRM every 1 second, say, then update
a percent complete counter, based on some innate knowledge of the
calculation. To get this to IDL under call_external is more difficult.
You *could* then just print it to the terminal, ala:
printf("\r%02d%% complete",percent_complete);
Make sure to:
setbuf(stdout,(char *)NULL);
first, so the updates will appear.
Of course, RSI would frown on this, but if it gets the job done...
If you'd like to do it full blown way, with a snazzy graphical update
slider, you might have to make a full DLM, and use IDL_Execute to force
the progress update from the C side. That's a lot of work for a bit of
eye candy. But everybody likes candy.
Good luck,
JD