Re: Tip: how to mix object gui with command line [message #18359] |
Mon, 20 December 1999 00:00 |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Karri Kaksonen (karri.kaksonen@picker.fi) writes:
> I just thought of dropping a line about a discovery I made.
> This may be old news for all old timers but as it was new for
> me I thought of sharing this idea.
>
> When you build an application as an object like:
> o=obj_new('MyApplication')
>
> and you start up the graphical user interface with buttons etc.
> o->draw
>
> then I suddenly notice that there is something weird going on
> and want to have a look at my data from the command line.
>
> In a widget-program I would have to quit the program and start
> debugging. But in an object program I can leave the program
> running and just fetch the data.
>
> The key is in coding in methods for accessing private stuff like:
>
> function MyApplication::getdata
> return *self->data
> end
>
> then I can just click on the IDL> command line and write:
> a=o->getdata()
> and continue to work on it on the command line.
I think you meant "RETURN, *self.data".
But in any case, this is certainly possible to do. I would
be just a bit careful with it, however, since it is quite easy
to completely defeat the whole purpose of objects, which
is to encapsulate the data and the methods that work on
the data inside the object, out of the view of the rest
of the world.
For example, you can easily write a GetDataPointer method:
FUNCTION JUNKER::GetDataPointer
RETURN, self.data
END
Now the outside world can muck around with the data *inside*
the object. Oh, dear! Keep in mind that just because something
is *possible* doesn't mean it's always a good idea. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|