When you're doing the set to "" toward the end, you have it go from start
through (start + end), which goes beyond the end of the document, which
will cause an error. Try this for those 3 lines:
set theStart to selection's characterOffset
set theEnd to characterOffset of last character of text 1 of text
document 1
set (characters theStart thru theEnd of text document 1) to ""
-Kendall
On Wednesday, May 23, 2012 4:33:42 PM UTC-4, Lalock wrote:
>
> It seems like this should be easy, but everything I've tried has
> failed. I'm trying to do a find and replace, then delete from a given
> text point down to the end of the document. Here's my latest effort:
>
> tell application "BBEdit"
> activate
> open "test.txt"
> replace "°°" using "
> " searching in text 1 of text window 1 options {search mode:literal,
> starting at top:true, wrap around:false, backwards:false, case
> sensitive:false, match words:false, extend selection:false}
>
> tell text 1 of text document 1
> set find_results to find "
> @rule:" options {search mode:grep, starting at top:false, wrap
> around:true, backwards:false, case sensitive:false, match words:false,
> extend selection:false}
> set theStart to selection's characterOffset
> set theEnd to last character of text 1 of text document 1
> set (characters theStart thru (theStart + theEnd)) to ""
> end tell
>
> save window 1
> close window 1
> end tell
>
> Can anyone tell me what I'm doing wrong? The error I get highlights
> "last character" and gives the message: "BBEdit got an error: An
> attempt was made to resolve an Apple Event reference to a non-existent
> object (MacOS Error code: -1728)"
--
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>