I am trying to automate the insertion of a glossary text file into a group of open html documents. I am having no issue with inserting the glossary into the correct position of window 1, but I am having difficulties creating an AppleScript repeat rule to cycle through all the open windows. Can someone help me with this issue as I have been to many AppleScript sites, but can not seem to find the correct logic. Here is what I have so far, but this code locks my Mac (OS10.2.8 using BBEdit 7.03).
tell application "BBEdit"
activate
count windows
repeat with x from 1 to the result
find "</body>
" searching in text 1 of text window x options {search mode:literal, starting at top:true, wrap around:false, reverse:false, case sensitive:false, match words:false, extend selection:false} with selecting match
set selection of window x to "</body>
"
select insertion point after selection of window x
find "</body>
" searching in text 1 of text window x options {search mode:literal, starting at top:false, wrap around:false, reverse:false, case sensitive:false, match words:false, extend selection:false} with selecting match
insert glossary entry inserting alias "newHD:Applications:BBEdit 7.0:BBEdit Support:Glossary:satag.txt" into text window x
save text window x
close text window x
end repeat
end tell