Thanks, Jim.
I had not listed all my unsuccessful attempts because the example I
cited was sort of generated by AppleScript. I had tried
quote:
tell application "BBEdit"
activate
open alias "Mac Mini HD:Users:Bull:Desktop:Found Text.txt"
find "abcde" searching in text 1 of text document 1 options {search
mode:grep, starting at top:false, wrap around:true, backwards:false,
case sensitive:false, match words:false, extend selection:false} with
selecting match
copy selection
set myString to "Mac Mini HD:Users:Bull:Desktop:" & found text &
".html"
close text document 1 saving no
end tell
Unquote
Treating, in this attempt "found text" as a text string. The event log
came back:
quote
tell application "BBEdit"
activate
open alias "Mac Mini HD:Users:Bull:Desktop:Found Text.txt"
--> text document 1
find "found" searching in text 1 of text document 1 options {search
mode:grep, starting at top:false, wrap around:true, backwards:false,
case sensitive:false, match words:false, extend selection:false} with
selecting match
--> {found:true, found object:characters 57 thru 61 of text
document
1, found text:"found"}
copy selection
get found text
--> error number -10009
Result:
error "Can’t make «class MTxt» of application \"BBEdit\" into type
Unicode text." number -1700 from «class MTxt» to Unicode text
unquote
I saw that AppleScript had inserted a new command after "copy
selection", namely, "get found text". So I modified the script to
explicitly perform that action,first without parens then with, with
the result I showed.
Again, thanks for the advice. "AppleScript 1-2-3" does not address
records until page 580, and I haven't got there yet.
Bull
Blacksburg, VA
On Jan 13, 4:11 pm, Jim Correia <[email protected]> wrote:
> On Jan 13, 2010, at 3:55 PM, Bull wrote:
>
> > The AppleScript log shows, after the successful search, the result '--
> >> {found:true, found object:characters 154 thru 158 of text document
> > 1, found text:"abcde"}'.
>
> > "abcde" is the text that I want to use for my string. But, for
> > example, "get (found text)" results in 'error "BBEdit got an error:
> > Can’t make found text into type found text." number -1700 from found
> > text'. Different attempts to refer to "found text" get different
> > errors.
>
> It is usually useful to show us what you tried, so we can show you how you
> went wrong without guessing.
>
> get (found text) is meaningless in this context.
>
> The find verb returns you a record, and you access the found text field of
> that record.
>
> For example:
>
> tell application "BBEdit"
> tell text window 1
> set theFindResult to find "foobar"
> if found of theFindResult then
> set s to found text of theFindResult
> display alert s
> end if
> end tell
> end tell
>
> - Jim
--
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.