I'm not sure what I started but I certainly appreciate the help, Rich and 
Chris
- D
On Monday, May 24, 2021 at 9:40:32 PM UTC-6 [email protected] wrote:

> On 05/24/2021, at 21:44, Rich Siegel <[email protected]> wrote:
>
> his is a good script. Some feedback: as a matter of best practices and 
> future proofing, avoid targeting windows (or elements of them).
>
> ------------------------------
>
> Hey Rich,
>
> Thanks for the feedback.
>
> Actually I often use this sort of construct:
>
> ------------------------------
>
> *tell* *application* "BBEdit"
>     *activate*
>     *set* myDoc *to* *make* new *text document* with properties {*text*:"some 
> text"}
>     *return* myDoc
> *end* *tell*
>
> --> text document 1 of application "BBEdit"
>
> ------------------------------
>
> What I don't like about it is the reference it creates – it will break if 
> you change the window index in the script and then refer to the reference 
> again.
>
> ------------------------------
>
> Getting a reference to any document besides document 1 produces a more 
> sturdy reference:
>
> *tell* *application* "BBEdit"
>     *set* docRef *to* *document* 2
> *end* *tell*
>
> --> project document "untitled project 45" of application "BBEdit"
>
> ------------------------------
>
> If I need the reference to be more robust I have to do something like this:
>
> *tell* *application* "BBEdit"
>     *activate*
>
>     *set* docID *to* ID *of* (*make* new *document* with properties {
> *text*:"some text"})
>
>     
>     *tell* *document* *id* docID
>         *set* *after* *its* *text* *to* linefeed & "some more text" & 
> linefeed
>         *select* *insertion point* *after* *its* *text*
>     *end* *tell*
>
>     
> *end* *tell*
>
> Most of the time working with the front document is perfectly adequate – 
> but not always.
>
> ------------------------------
>
> --
> Take Care,
> Chris
>
>

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "[email protected]" 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/5774ac0c-15a3-4116-97e0-7d5d7c4138ffn%40googlegroups.com.

Reply via email to