Re: XForms: Addressing Input Field

John Culleton (john@ccpl.carr.lib.md.us)
Thu, 17 Dec 1998 12:26:10 -0500

# To subscribers of the xforms list from John Culleton <john@ccpl.carr.lib.md.us> :

Steve Lamont wrote:
>
> # To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :
>
> > Assume a simple form called foo created by fdesign with a single input
> > field called bar. I want to insert a value into the field from the
> > c-language program (specifically from a callback routine, not
> > necessarily the one for that field.)
> >
> > How do I address the field? Is it ui->bar or fdui->bar or fd_foo->bar
> > or what? The examples don't seem to deal with the simple situation of
> > moving data to an input field from a callback situation. I want to use a
> > statement like:
> >
> > fl_set_input(xxx->bar, stringvalue);
> >
> > I just need to know what to use in place of xxx, given a form named foo
> > and a field named bar. Please remember that I am using the output from
> > fdesign (all three source modules) so its naming conventions are in
> > force.
>
> If it's in the callback for the object itself, you'd use
>
> void input_callback( FL_OBJECT *ob, long data )
>
> {
>
> fl_set_input( ob, stringvalue );
>
> }
>
> If it's in some other callback in the same form, then you can do
>
> void some_other_callback( FL_OBJECT *ob, long data )
>
> {
>
> FD_some_form *fd_some_form =
> ( FD_some_form *) ob->form->fdui;
>
> fl_set_input( fd_some_form->bar, stringvalue );
>
> }
>
Thanks for your very complete reply. I tried the second solution you
propose viz:

#include "forms.h"
#include "foo.h"

/* callbacks for form foo */
void call_bar(FL_OBJECT *ob, long data)
{
FD_foo *fd_foo = (FD_foo *) ob->form->fdui;
char dummy[10];
sprintf(dummy, "test");
fl_set_input(fd_foo->bar, dummy);
}

When compiling I get the message:

foo_cb.c: In function `call_bar':
foo_cb.c:7: structure has no member named `fdui'

So something is still not right. What I am trying to do ultimately is
input a value in a field, use that value to search a data base, and post
the results to the remaining fields on the form.
This simple issue of addressabilty of the field is gumming up the works.
I tried taking the

FD_foo *fd_foo

statement in foo_main and making it global but that had no impact
either.

Is there somewhere a complete worked example of input field addressing
using the logic of the fdesign output? The examples shipped with the
package are hand coded and are enough different to cause confusion.

Sorry to be so dense. Life was easier in COBOL. Everything was global.
(Sigh)

John Culleton
john@ccpl.carr.org

(410) 795-1159
Please visit: http://www.carr.lib.md.us/~john/index.htm
_________________________________________________
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/