Horace,
>Date: 5 Nov 1999 12:51:16 -0800
>From: "Horace Ho" <[EMAIL PROTECTED]>
>Subject: TxtFindString??
>
>I tried to use TxtFindString() but failed. The code is:
>
> {
> Boolean f; ULong outPos; Word outLen;
> f = TxtFindString ("012345678", "4567", &outPos, &outLen);
> f = TxtFindString ("012345678", "0123", &outPos, &outLen);
> f = TxtFindString ("abcdefghi", "defg", &outPos, &outLen);
> f = TxtFindString ("abcdefghi", "abcd", &outPos, &outLen);
> }
>
>The results of 4 lines (shown in debugger) for f, outPos, and outLen are:
>
>1) 0, 0, 0
>2) 1, 0, 4
>3) 0, 0, 0
>4) 0, 0, 0
>
>Any hint?
1. The first problem is that the target string (string being searched
for) needs to be converted into the find string format. Normally this
is handled for you by the Find code, and the string it passes your
application in the strToFind field of the FindParamsType record has
already been munged.
Doing it yourself is harder. Basically you need to case on the
version of the OS, and do different things depending on whether it's
< 3.1, < 3.5, or >= 3.5. The released version of PalmOSGlue.lib will
have a TxtGluePrepFindString routine that handles all of this for you.
2. The second problem is that cases #1 and #3 above won't match
because the target string isn't at the beginning of a word. Remember
that the _current_ implementation of the Palm OS find code only
matches at the beginning of a string or a word, thus searching for
text inside of word won't work.
Note that the exact details of how a string gets munged by
TxtPrepFindString, and the search algorithm itself, are both subject
to change in future versions of the OS.
-- Ken
Ken Krugler
TransPac Software, Inc.
<http://www.transpac.com>
+1 530-470-9200 (direct) +1 408-261-7550 (main)