Re: XForms: problem with fl_get_input

Steve Lamont (spl@szechuan.ucsd.edu)
Sun, 12 Oct 97 18:45:43 PDT

To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :

> Well that worked but now I'm running into one more problem.
> ...
> 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.
> }

How is `cur_status' being assigned to one of the members of the
structure. You should probably be doing something such as

void status(FL_OBJECT *ob, long data)
{
const char *cur_status;
cur_status = fl_get_input(status_box);
p_dat.cur_stat = strdup( cur_status );
printf("%s\n", cur_status);
}

First of all, you aren't assigning anything to the structure member
and second, you should be duping the character array since it will
otherwise be clobbered the next time you call fl_get_input() (or
perhaps sooner, since I'm not sure how that buffer is internally
managed by XForms. In any case you should certainly not treat it as
an immutable area).

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://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/