From: "Timothy Beamish" <[EMAIL PROTECTED]>
> > >   /*** 's' remains blank throughout the following statements. What am
I
> > > doing wrong? ***/
> > >   error = DmWrite(s, OffsetOf(PackedAnimalInfoRecord, alphaRhythm),
> > >                      &src_record->alphaRhythm,
> > > sizeof(src_record->alphaRhythm));
> > >
>
> Yes, 's' displays "" in the variable list. But the value of alphaRhythm is
> '1' so 's'
> should display '1', correct?
>
Not if you've defined it as a char *.  You'll get 0x01 displayed
as a character, which is unprintable.  For this sort of debugging you're
better off using view memory to view the hex dump from that address.
This also makes it easier to confirm that each string is appended to
the data block, while a simple string display would stop at the first null
terminator.

> > > error = DmStrCopy(s, OffsetOf(PackedAnimalInfoRecord, key2),
> > >                     src_record->key2);
> > >
> > Is this right?  OffsetOf is good for writing fixed data into
> > structures but it's going only going to increment by one for
> > each successive key because that's how large they are in
> > the structure.  Don't you need to initialise an offset value to
> > Offset of the first string and then add StrLen + 1 to decide
> > where to write the next string?
>
> This is interesting. If I successfully place a string into 's' before
> getting to this statement,
> does the offset of 'key2' change? I assumed that OffsetOf
> would scan through the structure, noting when corresponding
> '/0' characters occur for each string field (thus
> figuring out the offset as it went along).
>
Nope, it's just a macro - you can check it out to see what it
does.  You'll have to manually write the code to increment
the pointer, but it's fairly trivial.

Chris Tutty


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to