Re: XForms: problem with fl_get_input

Scott (sbarron@n-link.com)
Sun, 12 Oct 1997 16:52:28 -0500 (CDT)

To subscribers of the xforms list from Scott <sbarron@n-link.com> :

On 12-Oct-97 Steve Lamont wrote:
->Looks fine to me. Are you certain `model_box' is of type FL_INPUT?
->As someone else suggested, you may want to add a newline ('\n')

Yes the ('\n') fixed that problem. I hadn't noticed that all the data would
get prited to the screen after I exited the applications. Thanks.
->The form you use is more appropriate to assign to a pointer:
->
-> struct {
-> ...
-> char *model;
-> ...
-> } p_dat;
->
->Also, bear in mind that fl_get_input() returns a pointer to an XForms
->internal buffer, the contents of which are subject to arbitrary
->change, so you should really do something like
->
-> p_dat.model = strdup( ( char *) fl_get_input(model_box) );
->
->to copy the contents of the buffer to your own area, which you should
->manage in appropriate the appropriate manner to prevent memory leaks.
->
->
spl

Well that worked but now I'm running into one more problem.

this is cut from my application_cb.c file:

#include "forms.h"
#include "pubs.dbase.h"

struct pubs_data {
char *techb;
char *model;
char *cur_stat;
char *change;
char *etb;
char *etbv;
} p_dat;

void status(FL_OBJECT *ob, long data)
{
const char *cur_status;
cur_status = fl_get_input(status_box); <---one of these for each member
printf("%s\n", cur_status); of the structure.
}

void enter_data(FL_OBJECT *ob, long data)
{
printf("%s\n", p_dat.techb);
printf("%s\n", p_dat.model);
printf("%s\n", p_dat.cur_stat);
printf("%s\n", p_dat.change);
printf("%s\n", p_dat.etb);
printf("%s\n", p_dat.etbv);
}

The enter_data function will eventually send all the data from the structures
to a mysql command but when I hit the enter button I get this to the screen:

tb number
(null)
(null)
(null)
(null)
(null)

Seemingly only the first member is getting written to but in each of the
callbacks the printf("%s\n", p_dat.???) will print the correct data.

Sorry this is taking so long for me to get, but I am just learning about
structures and pointers in C. I really appreciate all the help you've given me
so far.

Thanks,
Scott
_________________________________________________
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/