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