These are my functions in case you see something I don't.
/***********************************************************************
*
* FUNCTION: PackInfo()
*
* DESCRIPTION: This routine packs an unpacked Info structure
*
* PARAMETERS: info - Pointer to a Info structure
* tblInfoDBEntry - Handle
*
* RETURNED: void
*
***********************************************************************/
void PackInfo(tblInfoPtr info, VoidHand tblInfoDBEntry)
{
// Figure out necessary size
UInt length = 0;
CharPtr s;
UInt offset = 0;
length = sizeof(info->UnitType) + sizeof(info->Beginning +
sizeof(info->Ending) + sizeof(info->Number) +
StrLen(info->TNumber) + StrLen(info->TNumber2) +
StrLen(info->Driver) + StrLen(info->StartDate) +
StrLen(info->EndDate) + StrLen(info->Origin) +
StrLen(info->Destination) +
7; // 7 for string terminators
// Resize the VoidHand
if(MemHandleResize(tblInfoDBEntry, length) == 0)
{
// Copy the fields
s = MemHandleLock(tblInfoDBEntry);
DmWrite(s, offset, (CharPtr) &info->UnitType,
sizeof(info->UnitType));
offset += sizeof(info->UnitType);
DmWrite(s, offset, (CharPtr) &info->BeginningOdometer,
sizeof(info->Beginning));
offset += sizeof(info->Beginning);
DmWrite(s, offset, (CharPtr) &info->EndingOdometer,
sizeof(info->Ending));
offset += sizeof(info->Ending);
DmWrite(s, offset, (CharPtr) &info->Number, sizeof(info->Number));
offset += sizeof(info->Number);
DmStrCopy(s, offset, (CharPtr) info->TNumber);
offset += StrLen(info->TNumber) + 1;
DmStrCopy(s, offset, (CharPtr) info->TNumber2);
offset += StrLen(info->TNumber2) + 1;
DmStrCopy(s, offset, (CharPtr) info->Driver);
offset += StrLen(info->Driver) + 1;
DmStrCopy(s, offset, (CharPtr) info->StartDate);
offset += StrLen(info->StartDate) + 1;
DmStrCopy(s, offset, (CharPtr) info->EndDate);
offset += StrLen(info->EndDate) + 1;
DmStrCopy(s, offset, (CharPtr) info->Origin);
offset += StrLen(info->Origin) + 1;
DmStrCopy(s, offset, (CharPtr) info->Destination);
MemHandleUnlock(tblInfoDBEntry);
}
}
/***********************************************************************
*
* FUNCTION: UnpackInfo()
*
* DESCRIPTION: This routine unpacks a packed Info structure
*
* PARAMETERS: info - Pointer to a Info structure
* packedInfo - Pointer to a packed Info structure
*
* RETURNED: void
*
***********************************************************************/
void UnpackInfo(tblInfoPtr info, const tblPackedInfoPtr packedInfo)
{
const char *s = packedInfo->Strings;
info->UnitType = packedInfo->UnitType;
info->Beginning = packedInfo->Beginning;
info->Ending = packedInfo->Ending;
info->Number = packedInfo->Number;
info->TNumber = s;
s += StrLen(s) + 1;
info->TNumber2 = s;
s += StrLen(s) + 1;
info->Driver = s;
s += StrLen(s) + 1;
info->StartDate = s;
s += StrLen(s) + 1;
info->EndDate = s;
s += StrLen(s) + 1;
info->Origin = s;
s += StrLen(s) + 1;
info->Destination = s;
s += StrLen(s) + 1;
}
--
Tim Astle
Tim Astle <[EMAIL PROTECTED]> wrote in message
news:8529@palm-dev-forum...
>
> Actually, the Byte is at the first of my record. Everything after it
works
> fine. This leads me to believe it works... because if it didn't the
offset
> would be off. Correct?
>
> By the way, the debugger just fatally crashed my Palm. I had to do a hard
> reset.
>
> --
>
> Tim Astle
>
>
> Fredrik Jagenheim <[EMAIL PROTECTED]> wrote in message
> news:8528@palm-dev-forum...
> >
> >
> > Sadly, having the record unpack correctly except for one field doesn't
> mean
> > it unpacks it correctly.
> > You said earlier that you added a Byte to the structure:
> > (Stupid example struct)
> > typedef struct {
> > char* textString;
> > char* anotherTextString;
> > Byte myNewByte;
> > float floatingNumber;
> > } my_struct;
> >
> > Just because textString and anotherTextString works fine after the
> addition
> > of the Byte doesn't mean that the floatingNumber works fine.
> >
> > I recommend that you start getting familiar with the debugger. You will
> need
> > it in the future. :)
> >
> > file://Fredde
> >
> >
> > On Mon, Apr 17, 2000 at 12:48:45PM -0300, Tim Astle wrote:
> > > Well, I assume the information gets unpacked correctly because I have
no
> > > problem accessing other data in the record. I'm not too familiar with
> the
> > > debugger...
> > >
> > > --
> > >
> > > Tim Astle
> > >
> >
> >
>
>
>
>
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html