Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!hplabs!hp-pcd!hpcvlx!ben From: ben@hpcvlx.HP.COM (Benjamin Ellsworth) Newsgroups: comp.windows.x Subject: Re: Help on Resource Conversion anyone? Message-ID: <100920054@hpcvlx.HP.COM> Date: 13 Feb 89 19:06:31 GMT References: <9499@cit-vax.Caltech.Edu> Organization: Hewlett-Packard Co., Corvallis, OR, USA Lines: 43 > I'd like to be able to specify a floating point resource and use > XtSetArg to modify it on the creation of a widget. > > ... I want to be able to say: > > XtSetArg(arg[n], XtSomeResource, 1.00); n++; > XtCreateManagedWidget(..., arg, n); > > and have my "thing.floating_field" field set to "1.00" > > I've tried adding a class_init routine which does an > > XtAddConverter(XtRFloat, XtRFloat, CvtFloatToFloat, NULL, 0); > > but although this gets called, CvtFloatToFloat (which I've written) > is NEVER called. > > Anyone have a clue as to what I've done wrong? This is a brain bug. You must realize that converters are "NEVER" called on arguments that are passed in via arglists. It is assumed that the application has loaded the right type in the arglist. [ The following may not apply to you on your machine. ] Unfortunately, this is where funny little compiler/architecture problems come into play. The type of arg.value is caddr_t. Due to the implementation of promotion rules on some machines (I'm not a compiler wizard, so the implementation could be entirely correct), when a float is assigned to a caddr_t, it is converted to an int. But you don't want an int? Too dang bad. You'll have to come up with a work-around. Good Luck, ----------------------------------------------------------------------- Benjamin Ellsworth | ben%hp-pcd@hp-sde.sde.hp.com | INTERNET Hewlett-Packard Company | {backbone}!hplabs!hp-pcd!ben | UUCP 1000 N.E. Circle | (USA) (503) 750-4980 | FAX Corvallis, OR 97330 | (USA) (503) 757-2000 | VOICE ----------------------------------------------------------------------- All relevant disclaimers apply. -----------------------------------------------------------------------