How Do I Set Specific Document/Tab as FrontMost?

(Jim Underwood) #1

Hey guys, this is my first attempt at scripting SD6, and I need a little help please.

###I’m writing a script to toggle between two Tabs as being frontmost.

I can see how to get a list of documents, but not Tabs. Are they the same thing?
Even with a document reference, I don’t see how to make it frontmost.

From the SD6 SDef:

A script window can contain multiple documents (scripts) as tabs. Script window properties that are really document properties apply to the current document (the frontmost tab).

current document get document The script document being displayed in this window (in the frontmost tab, if the window has multiple documents).

The “current document” is a “get only” property. How do I set it?

So the text refers to “tab”, but I don’t see a “tab” element anywhere.

TIA for your help.

P.S. Is there a library or collection of scripts somewhere that provide examples of how to script SD6?

(Mark Alldritt) #2

I think this is an oversight on our part. The intent was for you to be able to set the script window's current document property to switch tabs. I also suspect I meant to support selecting documents within a script window, but that does not work either.

I’ve filed a bug at my end and I’ll try and get this resolved for 6.0.5.

No, nothing is available.

(Jim Underwood) #3

Mark, thanks for the quick and helpful reply.
I can stop beating my head against a brick wall now. :wink:

So, do I understand you correctly that I’ll be unable to complete my script of toggling tabs until SD 6.0.5 is released?

(Mark Alldritt) #4

No promises as I’v not yet looked at the code to see why I did’t do this in the first place.

(Mark Alldritt) #5

Just took a look and I don’t see any reason why this will be a problem to fix. The change will be in 6.0.5.

(Jim Underwood) #6

OK, that’s great Mark. Thanks for the fast response and outstanding service.

(Mark Alldritt) #7

Here is one of my silly test scripts:

tell application "Script Debugger"
	tell script window 1
		repeat 10 times
			set current document to some item of (get documents)
		end repeat
	end tell
end tell

(Jim Underwood) #8

Mark, I’ve been testing the SD6 6.0.5 Beta, and the “current document” property is now settable. Thanks.

I’m writing a script/macro that will toggle between the last two documents (tabs?) that the user has viewed. So I need to store a reference to each document outside of a running script. Any ideas on the best method to do that?

(Mark Alldritt) #9

It depends how persistent this needs to be. If a per-Script Debugger launch persistence is sufficient, then you can use document ID. If you need something more, then I would use document path.

(Jim Underwood) #10

Yep, that is all I need. I’ll do some testing later to make sure I understand how to use the ID to set the “current document”.


(Mark Alldritt) #11

It should be simple. Get the document’s id from the id property. You can then reaquire the document using an ID object specifier:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

set theDocID to id of some document
tell document id theDocID
end tell