I collect recipes. One aspect of that is formatting them to a common
standard -- always using "Tbsp." instead of "T", "T.", "tblspn", and so
on. Since lots of different folks write recipes, there are a *lot* of
different combinations to be searched for and changed -- teaspoons,
tablespoons, quarts, pounds, etc. etc.
I've put together an AppleScript that works fine *except* that it throws
two different kinds of errors, and that makes it very annoying to use.
Here's a snippet of the script:
tell application "TextWrangler"
activate
try
replace " t " using " tsp. " searching in document of text window 1
end try
try
replace " ts " using " tsp. " searching in document of text window
1
end try
try
replace " tsp " using " tsp. " searching in document of text
window 1
end try
....
and so on through about thirty different items.
Naturally, no single recipe, or group of recipes, will contain every one
of those strings, and whenever a string is not found, TextWrangler puts
up an error dialog informing me of that, which I have to clear manually.
I thought that putting each "replace" inside a "try" would solve the
problem, but clearly it did not.
And every time it *does* find a string to replace, it asks me if I want
to save the file -- which of course I do not want to do until all the
replacements have been made.
So, what do I add to the AppleScript to tell it:
1) that I do not care if it can't find some particular string, and
2) That I do not want the file saved every time it makes a change.
thanks
Isaac


|