Developer wrote:
Here is the code: itemList[i] = (char *) MemPtrNew(25); // 25 is maximum size of structPtr->fld_1 itemList[i] = structPtr->fld_1; // I think I am doing something terribly wrong here
Hey dude, you absolutly right. You do somehting terrible wrong there. You allocate room for the string (25 bytes). Then in the next line you overwrite the pointer to the allocated room with the pointer you got from the record. But later on, you unlock the record pointer. So you lost the allocated room and you lost the pointer from your record. Bad luck. You better take the allocated room and copy the content!!!! from the record into the allocated room. Then everything will be right.
So you have 2 ways:
The quick and dirty and with 2 main assumptions:
the string is never longer than 24 bytes and you have a 0x00 at the end of the string. Then you could use
StrCopy(itemList[i], structPtr->fld_1); (Is the source and destination in the correct order?)
the other way is much more safe:
StrNCopy(itemList[i], structPtr->fld_1, 25); // only copy up to 25 bytes itemList[i][24] = 0x00; // take care about the 0x00 at the end of the string
(Here again, I don't know by heart the correct order of source and destination.)
Regards Henk
-- ------------------------------------------------------------------------- Henk Jonas Palm OS � certified developer
[EMAIL PROTECTED] www.metaviewsoft.de -------------------------------------------------------------------------
-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
