Fletcher:

You have given me what I need, especially from your second idea. You have 
answered several puzzles at once, including what that "with selecting 
match" is for.

I didn't realize that "\S" includes line endings.

I had some trouble with ".*" in replace, so used the 'found object' 
property of Search Match, the result of a find operation. I am finally 
starting to know how to use that dictionary thing. Took some learning.


Rich:

Thank you for your help. I have used both the AppleScript Language Guide 
and the dictionaries, but still needed more explanations. I am finally 
getting to the point where I don't get cryptic errors on 9 tries out of 
10. I think I needed to start asking questions at forums sooner, and 
searching out examples of basic operations, such as getting a text document 
ready to edit. Hard to find.

I suspect in hindsight that BBEdit's factories may have been an easier 
approach, but I'm glad to be better AppleScript.

--------------------------------------------

My current search & replace script is below in case anyone has feedback.

Thank you both for your help.
Hal

-------------------------------------------

set myFile to POSIX file "/Users/Hal/Documents/.../ScriptTarget.2.txt"
set findText to "is"
set replText to "isn't"
tell application "BBEdit"
activate
set myDoc to open myFile
set myWindow to window of myDoc
find findText searching in myDoc with selecting match
replace found object of result using replText searching in selection of 
myWindow
close myWindow saving yes
end tell -- BBEdit

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "supp...@barebones.com" rather than 
posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/9a0800b9-3123-418c-8c48-70c545539d93%40googlegroups.com.

Reply via email to