Re: XForms: Demo dirlist, comes with distribution

Thomas L. Gossard (tgossard@ix.netcom.com)
Thu, 05 Mar 1998 21:50:45 -0500 (EST)

# To subscribers of the xforms list from "Thomas L. Gossard" <tgossard@ix.netcom.com> :

Steve,

Sorry I'm so late in replying. Thanks for the info. It may take a bit
getting used to, but I'll live. Seems somewhat circular to me, like
having a structure point to itself by way of a "medium". Thanks again
for your help.

Tom
On 02-Mar-98 Steve Lamont wrote:
># To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont)
># :
>
>> fdui->fbform->fdui = fdui;
>>
>> What is the general idea of this line. This seems to me to be seting the
>> forms fdui pointer to a pointer that is pointing to the form just defined.
>
> Exactly.
>
> The idea is that if you need to access the structure from a callback
> you don't need a global variable. Global variables, according to some
> theories of C programming, are Considered Harmful and to be avoided.
>
> For instance, if the callback function `some_callback' which is called
> to handle some action for an object in the form `whatever' needs to
> access other members of the FD_whatever structure, you could code
> something like
>
> void some_callback( FD_OBJECT *ob, long data )
>
> {
>
> FD_whatever *whatever = ( FD_whatever *) ob->form->fdui;
>
> [...]
>
> Then you could manipulate any of the objects in that structure as you
> desire.
>
> As I said, this presupposes that the callback is invoked from an
> object that is part of the FD_whatever structure. If if isn't then
> you either need to resort to a global pointer or some other mechanism,
> such as a pointer to structure attached to all FD_* structures which
> provides a place to hang pointers to any other structures.
>
> It can be a bit confusing at first but once you set these things up
> the first couple of times it becomes pretty much second nature.
>
> spl
>
> _________________________________________________
> To unsubscribe, send the message "unsubscribe" to
> xforms-request@bob.usuf2.usuhs.mil or see
> http://bob.usuf2.usuhs.mil/mailserv/xforms.html
> XForms Home Page: http://bloch.phys.uwm.edu/xforms
> List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/

Thomas L. Gossard
tgossard@ix.netcom.com
----------------------------------------------------
"It is said that the gods play games with the lives of men. But what games,
and why, and the identities of the actual pawns, and what the game is,
and what the rules are - who knows?
Best not to speculate.
Thunder rolled. ...
It rolled a six."

from "Guards! Guards!" by Terry Pratchett

_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/