Cheers for that - My AppleScript knowledge is, well, limited at best, but I
managed to run your script to get a consistant switching between 3 files,
even if those 3 files weren't the top 3 on either the currently open or
recen document list - but, most importantly, it's consistant.

Thanks, you've given me something to play with, even if it only ends up
improving my BBEdit scripting skills.

Dave


On 3 January 2013 15:48, Christopher Stone <[email protected]>wrote:

> On Jan 01, 2013, at 20:14, David Shea <[email protected]> wrote:
>
> I've tried creating a script to switch between open files in a project by
> recording myself clicking on files in the windows palette. I get, in the
> script, stuff like
>
>
> "select text document X of project window 1"
>
> Where X, to me, seems like a random number - I can click on several files,
> and X might, or might not change - so I can't have a script where X is
> 1,2,3, etc... and assign to cmd-1, cmd-2 etc...
>
> ______________________________________________________________________
>
> Hey David,
>
> [Obviously I've changed the topic.]
>
>
> -------------------------------------------------------------------------------------------
>
> tell *application* "BBEdit"
>   *select* *text document* 2 of *project window* 1
>   *select* *text document* 2 of *project window* 1
> end tell
>
>
> -------------------------------------------------------------------------------------------
>
> Recording Applescript is often a mixed bag that takes sorting out.
>
> What you've gotten above is perfectly logical, since BBEdit simply keeps
> track of the index of open documents, and that changes every time you move
> a different one to the frontmost position.
>
> So we have to find a means to reference them by a more sturdy identifier:
>
>
> -------------------------------------------------------------------------------------------
>
> tell *application* "BBEdit"
>   tell *project window* 1
>     if (*count* of (*documents* where its name does not end with
> ".bbprojectd")) ≥ 1 then
>       set AppleScript's text item delimiters to return
>       set docIDs to (ID of *documents* where its name does not end with
> ".bbprojectd") as *text* --» ERROR
>       set docIDs to (*sort lines* docIDs)
>       repeat while last *character* of docIDs is return
>         set docIDs to *text* 1 thru -2 of docIDs
>       end repeat
>       set docIDs to *text items* of docIDs
>       set firstDoc to *document* id (get *item* 1 of docIDs)
>       *select* firstDoc
>     end if
>   end tell
> end tell
>
>
> -------------------------------------------------------------------------------------------
>
> I don't feel like fooling with this much, but I've come up with this q&d
> (quick & dirty) proof-of-concept.
>
> By doing a little error-detection and changing the index you can create
> multiple scripts and bind them to Cmd-1, Cmd-2, etc — then if say 4
> documents are open Cmd-4 will switch to the fourth one in ID-order — if
> only three documents are open it can beep at you or something.
>
> It should also be possible to use this basic technique to switch between
> open windows.
>
> What I do personally for windows is use Keyboard Maestro to open the
> Window Menu via a hotkey and then I type-select what I want.  (This can
> also be done via Applescript and System Events.)
>
> You could also set up custom assignment keys - I.E. say Ctrl-1 will
> assign the frontmost document to Cmd-1 - etc.
>
> This at least should give you some food for thought.
>
> --
> Best Regards,
> Chris
>
>  --
> --
> 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>
>
>
>
>

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