On Wednesday, October 10, 2012, David Schutz <[email protected]> wrote:

set theProj to project document 1
repeat with n from 1 to (count items of theProj)
set currentFile to file of item n of theProj
open currentFile
set currentWin to text document (name of item n of theProj)
-- do stuff
save currentFile
close currentFile
end repeat

A couple of things:

*   "close" can only apply to windows or documents.

* When you open a document, the "open" even returns a reference to
    the document that was just opened.

* You should always target documents whenever possible, and never windows, because you can never be guaranteed a one-to-one relationship between
    documents and windows.

Put these together, and you get:

    set openedDocument to (open currentFile)

    ...

    save openedDocument
    close openedDocument

You might also consider using a text factory, which is designed to handle this sort of automation for projects.

Enjoy,

R.
--
Rich Siegel                                 Bare Bones Software, Inc.
<[email protected]>                      <http://www.barebones.com/>

Someday I'll look back on all this and laugh... until they sedate me.

--
--
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>



Reply via email to