Andre Augusto <[EMAIL PROTECTED]> writes:
> Hello everybody!
> I have a structure that contains 3 attributes. I have a form that shows the
> information that exist in that record, that is, the 3 attributes. I want to
> know how can I change only 1 attribute, without changing the other 2. I use
> simple API functions to create the record like DmNewRecord, MemSet, DmWrite
> and to change the record I use DmGetRecord and DmWrite again.
if you got a structure like this:
struct MyStruct {
int attr1;
int attr2;
int attr3;
}
struct MyStruct var;
then you do just var.attr2 to change e.g. the 2nd attribute.
If your referring to a struct in the storage ram (Database), and changing one,
without reading the complete record beforehand, then you could do it with
DmWrite and giving an offset. Therefor you must calculate the offset of the
attribute in the struct. You can either do that manually (not recommended!) or
use the offsetof Macro:
#include <stddef.h> // contains the macro
DmWrite(record, offsetof(struct MyStruct, attr2),
&newValue, sizeof(newValue));
So you can write direct at the required offset. The macro calculates the
offset for you, so you dont have to worry about the offset in case of changing
the struct (it does it by casting to 0 and getting address:
offset = &(((struct MyStruct *)0)->attr2); )
Florian
--
int m,u,e=0;float l,_,I;main(){for(;1840-e;putchar((++e>907&&942>e?61-m:u)
["\t#*fg-pa.vwCh`lwp-e+#h`lwP##mbjqloE"]^3))for(u=_=l=0;79-(m=e%80)&&
I*l+_*_<6&&26-++u;_=2*l*_+e/80*.09-1,l=I)I=l*l-_*_-2+m/27.;}
--
For information on using the Palm Developer Forums, or to unsubscribe, please
see http://www.palmos.com/dev/support/forums/