Re: newbie question: how to read a string from a MemHandle?
correction, should be err = MemHandleResize(h, MemHandleSize(h)+(len+1)); From: Gearoid Murphy [EMAIL PROTECTED] Reply-To: Palm Developer Forum [EMAIL PROTECTED] To: Palm Developer Forum [EMAIL PROTECTED] Subject: Re: newbie question: how to read a string from a MemHandle? Date: Thu, 07 Aug 2003 11:10:16 +0100 err = MemHandleResize(MemHandleSize(h)+(len+1)); -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/ _ Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/ _ Add photos to your e-mail with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: newbie question: how to read a string from a MemHandle?
I'm not sure what you are doing wrong. As I see it to write the data to the handle you should be doing something like the following: // global MemHandle MemHandle h = NULL; // Append data to whatever is already in handle void WriteDataToHandle(Char *dataInP) { Char *strP; Err err; UInt16 len = StrLen(dataInP); if (!h) { h = MemHandleNew(len+1); if (h) { strP = (Char *)MemHandleLock(h); if (strP) { StrCopy(strP, dataInP); MemHandleUnlock(h); } } } else { err = MemHandleResize(MemHandleSize(h)+(len+1)); if (!err) { strP = (Char *)MemHandleLock(h); if (strP) { // Append data StrCat(strP, dataInP); MemHandleUnlock(h); } } } } // Read data from handle void ReadDataFromHandle() { Char *strP = NULL; if (h) { strP = (Char *)MemHandleLock(h); if (strP) { DisplayStr(strP); MemHandleUnlock(h); } } } // Finally free handle MemHandleFree(h); Regards, Ger From: blaman [EMAIL PROTECTED] Reply-To: Palm Developer Forum [EMAIL PROTECTED] To: Palm Developer Forum [EMAIL PROTECTED] Subject: Re: newbie question: how to read a string from a MemHandle? Date: Thu, 7 Aug 2003 11:30:08 +0200 at first thanx for your reply. However, when i try to access strP my programm crashes telling me it read memory from the memory manager data structures. Any idea what i did wrong? i locked the handle to write it, unlocked it, locked it again by strP = (Char *)MemHandleLock(h); accessed strP and it crashed. Gearoid Murphy [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Char *strP; strP = (Char *)MemHandleLock(h); // h is a MemHandle if (strP) { // Do stuff with strP } // Make sure to unlock MemHandle MemHandleUnlock(h); -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/ _ Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: newbie question: how to read a string from a MemHandle?
at first thanx for your reply. However, when i try to access strP my programm crashes telling me it read memory from the memory manager data structures. Any idea what i did wrong? i locked the handle to write it, unlocked it, locked it again by strP = (Char *)MemHandleLock(h); accessed strP and it crashed. Gearoid Murphy [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Char *strP; strP = (Char *)MemHandleLock(h); // h is a MemHandle if (strP) { // Do stuff with strP } // Make sure to unlock MemHandle MemHandleUnlock(h); -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: newbie question: how to read a string from a MemHandle?
Char *strP; strP = (Char *)MemHandleLock(h); // h is a MemHandle if (strP) { // Do stuff with strP } // Make sure to unlock MemHandle MemHandleUnlock(h); From: blaman [EMAIL PROTECTED] Reply-To: Palm Developer Forum [EMAIL PROTECTED] To: Palm Developer Forum [EMAIL PROTECTED] Subject: newbie question: how to read a string from a MemHandle? Date: Thu, 7 Aug 2003 10:54:17 +0200 hi everbody, i am new to palm and its memoryhandles. I receive a string and have to store it in a MemHandle, because i resize it in a loop while receiving the data. However, i´ve got no idea how to read the data from the handle, neither a normal (char*) cast, nor a sprintf works. I´m sure it is pretty easy but i don´t know how to do it :o| thanx in advance, Jan Pfluger -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/ _ The new MSN 8: advanced junk mail protection and 2 months FREE* http://join.msn.com/?page=features/junkmail -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/