scripted find and find again...
J. Landman Gay
jacque at hyperactivesw.com
Sun Jun 27 15:49:13 EDT 2021
I've never tried it but I know it's possible because the script editor does
it. I haven't looked at the scripts in the editor but if you're ambitious
you could.
If I had to do this myself from a cold start, I think I'd use offset with
its skip parameter to sequentially find occurances of the search term in
the text, and keep a list of the offsets as I go. You could do it two ways.
1. Find the first instance and record its offset. Record each subsequent
instance as the user repeats the search. The list would grow incrementally,
and to go backward, the previous instance would just be the line before the
current one.
2. Find all offset instances and record them whenever the search term
changes to get a complete list. You'd need to keep track of which line is
the current instance so you can calculate the one before it as per above.
This method is probably what you'd need to do if you want the search to
start at the bottom of the text or to wrap around to the bottom when going
backwards.
--
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
On June 26, 2021 12:21:57 PM Paul Dupuis via use-livecode
<use-livecode at lists.runrev.com> wrote:
> I suspect may of us on this list have coded their own Find and Find
> Again (or Find Next) commands.
>
> Some may use the Livecode "find" command (find [form] textToFind [in
> field]), but I suspect most (as even the Dictionary entry for Find
> recommends this) use offset or matchText.. Either approach, using
> "Find"or using "offset: (or equivalent) let you do Forward searches
> without jumping through hoops.
>
> Many typical applications (MS-Word for example) support searching in
> either direction, forward or backwards. It appears Livecode's language
> has no support for Backwards searching. I found this positively ancient
> enhancement request:
>
> https://quality.livecode.com/show_bug.cgi?id=946 (from 2003!!!)
>
> So, I have the following questions:
>
> 1) Has anyone scripted text search (of a field or variable content)
> that support forward and backwards searching?
>
> 1.1) As the equivalent of Find and Find Again
>
> 1.2) With hints, so it shows you snippets of the matches for you to jump
> to one rather then advancing sequentially through them?
>
> 2) I know the mother ship does not generally comment about future
> features, bit is any enhancement to scripted searching planned for
> LiveCode 10 or soon after?
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list