Re: XForms: Demo dirlist, comes with distribution

Steve Lamont (
Sun, 1 Mar 98 21:52:17 PST

# To subscribers of the xforms list from (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.


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

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.


To unsubscribe, send the message "unsubscribe" to or see
XForms Home Page:
List Archive: