Nigel Grant wrote:
Hi Henk
I have found that if I move the 2 alerts in before the line
MemPtrFree(strSub1);
as per ( Code Sample ) below then it works.
As soon as I issue the MemPtrFree(strSub1) then strSub2 = "" [...] How can I get the second variable to be maintained after the MemPtrFree(strSub1)
Nigel,
just remember what a string in C is: just a pointer to a place in memory which contains characters and which is terminated by 0x00. The code allocates it's own memory, to actually store both strings strSub1, and strSub2. Both stored in one memory block, splitted by 0x00 and having a second pointer (strSub2) pointing to the begin of the second string. strSub2 is (strSub1 + StrLen(strSub1) + 1) btw.
When you free this memory (MemPtrFree(strSub1)) you will loose both strings.
So what to do? Use a global variable, initialize it to NULL, and free it when your app terminates.
Regards Henk
-- ------------------------------------------------------------------------- Henk Jonas [EMAIL PROTECTED] Palm OS � certified developer
Please contact me, if you need an off-side contract worker. -------------------------------------------------------------------------
-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
