From: "Jamie McMullin" <[EMAIL PROTECTED]> > 2) The database I was given to do this project with IS packed. Although I'm not sure the format or how to unpack it. It would seem that /30 would delimete each record. > > The method I've seen is: > > char *s = PackedRecord->key; > UnpackedRecord->prodno = s; > s += StrLen(s) + 1; > Why this makes no sense at all is that PackedRecord->Key equals something like: > > '2938012/30AUTO_ADD/30100.20/30' etc. > > So I don't see how the above method of unpacking will turn that > long concatenated string into a bunch of indivdual, accurately > un-delimeted records. > It won't. That logic is intended for records that are packed with each string null-terminated, ie terminated by a character zero. You can then use StrLen to find the number of characters up to the next null-terminator. You can still use this logic, but you would have to write a function to count the number of characters from the pointer to the next /30 and then use that instead of StrLen.
All that pack really means is that instead of storing strings padded with spaces to a constant length as in '2938012 AUTO_ADD 100.20 ' '2938013 SOME OTHER DATA100.20 ' '2938013 THREE 100.20 ' they're terminated and the next field immediately follows them, as in '2938012\0AUTO_ADD\0100.20\0' '2938013\0SOME OTHER DATA\0100.20\0' '2938013\0THREE\0100.20\0' etc. The main advantage to packing is that you don't waste space padding strings out to the same length, the disadvantage is that you can't just dump the record into a C struct and access it immediately - you've got to copy the fields item by item into the structure you want to use. Part of your problem would seem to be the way this database was created, particularly since numeric data seems to have been turned into strings and might need to be converted back into numbers before you can calculate with it. On the other hand if you're just displaying these values it doesn't matter. Chris Tutty -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
