This is the way I would do it myself.  Just had to put my spoon in the
pot.  For character delimited data you want to do a StrChr on the
character that you use to separate the data.  Although if you don't need
to keep the original string intact you can just eat the string passed in
and avoid the extra memory use.

        -Aaron



>-----Original Message-----
>From: [EMAIL PROTECTED] 
>[mailto:[EMAIL PROTECTED] On Behalf Of Henk Jonas
>Sent: Wednesday, March 23, 2005 12:57 AM
>To: Palm Developer Forum
>Subject: Re: Toooooooooo much information -> StrChr or StrStr 
>or Glue + TxtFindString
>
>
>Nigel Grant wrote:
>
>> My string contains a phone number & a name eg. "me | +61 (0) 408 409 
>> 409"
>> 
>> I want to have two string variables that contain "me" & "+61 (0) 408 
>> 409 409"
>> 
>> Should I use StrChr or StrStr ?
>> 
>> I have tried to write my own, I'm having trouble as these 
>are pointers 
>> not values.
>> 
>> An example piece of code that I can study would be ideal :)
>
>Let's say strTemp is the pointer to your original string. We 
>will make a 
>copy of this string, find the "|" and alter the string to get two 
>pointers to the start of the first substring (strSub1) and the second 
>substring (strSub2).
>
>Char *strSub1, *strSub2;
>
>strSub1 = MemPtrNew(StrLen(strTemp) + 1);
>if (strSub1)
>{
>StrCopy(strSub1, strTemp);
>strSub2 = StrChr(strSub1, '|');
>if (strSub2)
>{
>    strSub2[0] = 0;
>    strSub2++;
>    // strSub1 has now the first substring, strSub2 the second, use it
>    // here
>}
>MemPtrFree(strSub1);
>}
>
>
>Regards
>Henk
>
>-- 
>---------------------------------------------------------------
>----------
>   Henk Jonas                                            
>[EMAIL PROTECTED]
>   Palm OS (r) 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/
>
>

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/

Reply via email to