On Dec 28, 2010, at 18:39, Lazeez wrote:
> I need the number returned in theCount. It worked correctly in 9.6.1. Am I 
> missing some sort of syntax error that I made? or is this a bug in 9.6.2?
______________________________________________________________________

Hey There,

I don't remember that working in previous versions.  In fact I was quite 
disappointed to discover that you couldn't find all-matches in the front text 
window.

>From the BBEdit Dictionary:

'found matches' 'get' 'list of Result Entry'  'for a multi-file or batch 
search, a list of the found occurrences'

This works fine with 9.6.1 and 9.6.2 (batch-find):

 set f to alias "Thor:Users:chris:test_directory:thegeekstuff:"
 tell application "BBEdit"
   set checkSearch to {search mode:literal, returning results:true, starting at 
top:true, showing results:false}
   set num_search to (find "Chris" searching in f options checkSearch)
   if found of num_search then
         set found_instances to found matches of num_search
         set theCount to count found_instances
   end if
 end tell

On my system both BBEdit versions fail silently if nothing is found, because 
that's how the script is written.  Both versions also throw the same error when 
something *is found* in the text of a text window, because only one item *cam* 
be found and there is *no* 'found matches' record.

The found record looks like this:

 {
   found:true, 
   found object:characters 415 thru 421 of text document 1 of application 
"BBEdit", 
   found text:"Chapter"
 }

(Prettified by Script Debugger)

Personally I'd be very glad if there were first-match and all-matches flags in 
the options (for working with an open text window).

For this sort of search I currently resort to the Satimage.osax:

 tell application "BBEdit"
         set srcData to text of text window 1
 end tell
 
 set searchString to "Chapter.*"
 set textToSearch to srcData
 
 set theResult to find text searchString ¬
         in textToSearch ¬
         case sensitive false ¬
         regexp true ¬
         whole word false ¬
         all occurrences true ¬
         without string result

--> Result:

 {
   {
         matchPos:414, 
         matchLen:9, 
         matchResult:"Chapter 1"
   }, 
   {
         matchPos:839, 
         matchLen:9, 
         matchResult:"Chapter 2"
   }
 }

Or with a switch you can get a simpler result:

--> Result:

 {
   "Chapter 1", 
   "Chapter 2"
 }

--
Chris

-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem, 
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

Reply via email to