Find/Count problem solved

Sarah sarahr at genesearch.com.au
Sun Apr 13 19:32:00 EDT 2003


Hi Nate,

I think you will find it much easier and faster to use the "filter" 
command.
Instead of your initial find and the repeat loop, just have:

put fld "Results" into tListToSearch
filter tListToSearch with "*" & cVar & "*"
put the number of lines in tListToSearch into tHitCount

The disadvantage is that this doesn't box each of the hits in the way 
your script does. Also, make sure that you filter a copy rather than 
the original data as filter is destructive and deletes any non-matching 
lines.

If you really need to box each of the hits, then I think offset (or one 
of it's variants) is a better option than find as you can explicitly 
tell it where it start looking. it will also operate on a variable 
rather than a filed which is always quicker.

Cheers,
Sarah
sarahr at genesearch.com.au
http://www.troz.net/Rev/


On Monday, April 14, 2003, at 08:20  am, ncouch wrote:

> After playing around with some ideas here is what I came up with for my
> problem.  My thanks to all for their help.
>
>
>
> on mFind
>
>   --setting things up
>   put empty into field "Hits"
>   select text of field "Results"
>   set the textStyle of selectedText to "plain"
>
>   put the number of lines of field "Results" into lCount
>   put 0 into x
>   global cVar,x
>
>   --asking for input
>   ask "What do you want me to find?"
>   put it into cVar
>   if cVar is empty then
>     exit mFind
>   end if
>
>   --finding the first string
>   -- and setting the initial mark
>   find cVar in field "Results"
>   put the foundChunk into temp1
>   set the textStyle of the foundChunk to "box"
>   add 1 to x
>
>   --finding the string
>   repeat until forever
>     find cVar in field "Results"
>     get the foundChunk
>
>     --data checks
>     if the foundChunk = temp1 then
>       exit repeat
>     end if
>     if the foundChunk is empty then
>       exit repeat
>     end if
>
>     add 1 to x
>     set the textStyle of the foundChunk to "box"
>
>   end repeat
>
>   -- here is what I found
>   put "Search string " & tab & tab & cVar into line 1 of field "Hits"
>   put "# of hits " & tab & tab & tab & x into line 2 of field "Hits"
>   put "Lines searched " & tab & lCount into line 3 of field "Hits"
>   set the vScroll of field "Results" to 0
>   set the hScroll of field "Results" to 0
>
> end mFind
>
>
>
> It works like a champ.
>
> Nate
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>
>
>
>





More information about the use-livecode mailing list