Re: XForms: pb with slider

Steve Lamont (spl@szechuan.ucsd.edu)
Wed, 20 Oct 99 15:21:23 PDT

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

> After compiling the attachment file (bjrxf2.c)

Does the attachment file actually compile? I had to fix two syntax
errors before I could get it to compile:

> #define DEBUG 1
> #ifdef DEBUG
> printf("point d'arr=E8t debug\n");
> #endif

This is illegal. Do you mean to define

#ifndef DEBUG
#define DEBUG printf("point d'arr=E8t debug\n");
#endif

? I'm not sure what your intent is.

> I've got 2 errors messages :
> 1)- In fl_set_object_label [util.c 43] Setting label of NULL object.
> 2)- A box "Choice" :XForms Error : fl_set etc....

> void slider_cb(FL_OBJECT *ob, long data)
> {
> char str[30];
> sprintf(str,"%f",fl_get_slider_value(ob));
> fl_set_object_label((FL_OBJECT *)data,str);
^^^^^^^^^^^^^^^^^

This is wrong. According to your callback definition

> fl_set_object_callback(sld, slider_cb, 0);

the value passed to slider_cb() is zero. Casting zero to FL_OBJECT
passes NULL to fl_set_object_label(), which is why you get the message

In fl_set_object_label [util.c 43] Setting label of NULL object.

Do you want to set the label of the slider to the value? If so, you'd
code

fl_set_object_label( ob, str );

although why you'd want to do that for a Value Slider is not clear,
since the value is already displayed.

Did you mean to pass a pointer to some other object to the callback
through the `data' argument? If so, this is *very* bad practice,
since pointers may not necessarily be the same length as a `long'
integer. Bizarre things may happen depending upon on what platform
you're running.

You should pass things like that via the `u_vdata' member of the
FL_OBJECT data structure, instead.

spl

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