Re: Xcode4 : AppleScript : How to get the current text document?
Re: Xcode4 : AppleScript : How to get the current text document?
- Subject: Re: Xcode4 : AppleScript : How to get the current text document?
- From: Jerry Krinock <email@hidden>
- Date: Wed, 03 Aug 2011 10:41:23 -0700
Getting the currently-open document is, you know, the first thing any AppleScript would normally do. Here are the failures I've racked up thus far:
The following gives me the workspace document instead of the text document:
set aDocument to document of window 1
This next one gives a document which Xcode seems to think is number 1, but is not the one in the frontmost window
set aDocument to file document 1
However, from this failure I conclude that a "file document" is what I want. But I don't know its index.
This next one gives Error -1728. "Xcode got an error: Can’t get file document of window 1."
set aDocument to file document of window 1
This next one gives Error -1728. "Xcode got an error: Can’t get file document 1 of window 1."
set aDocument to file document 1 of window 1
This next one gives Error -1728. "Xcode got an error: Can’t get file document 1 of project \"MyTest\" of workspace document \"MyTest.xcodeproj/project.xcworkspace\"."
set aWorkspace to document of window 1
tell aWorkspace to set aProject to project 1
tell aProject to set aDocument to file document 1
set aName to name of aDocument
This next one gives Error -1728. "Xcode got an error: Can’t get document 1 of project \"MyTest\" of workspace document \"MyTest.xcodeproj/project.xcworkspace\"."
set aWorkspace to document of window 1
tell aWorkspace to set aProject to project 1
tell aProject to set aDocument to document 1
set aName to name of aDocument
Now, I've written enough AppleScripts to know that some trial and error is always necessary. But I've run out of things to try. I would much appreciate any other suggestions anyone can think of.
On 2011 Aug 03, at 08:07, Jerry Krinock wrote:
> Has anyone figured out how to reference the text document which is currently being edited in Xcode 4's frontmost window?
>
> The following script:
>
> tell application "Xcode"
> set aDocument to file document 1
> set aName to name of aDocument
> log (aName)
> end tell
>
> seems to access a random document from within the project. How do I get the text document that I'm currently being edited in the frontmost window?
>
> Thanks,
>
> Jerry Krinock
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden