In article
,
dkletzing.DeleteThis@cfl.rr.com wrote:
> Here's the script that I managed to cobble together:
>
> set current_name to name of window 1
> tell application "BBEdit 6.0"
> save text document current_name
> end tell
> tell application "Textures"
> activate
> open file current_name
> end tell
>
> This gets me over to Textures but it doesn't open the file that is
> open in BBEdit. I suspect that current_name doesn't pick up the file
> path, so Textures doesn't know what to do. That's the place I'm having
> trouble with in the script. I don't know how to get the file path
> included in the initial set and how to call it once over in Textures.
You're right. The window name is just a name - and it's not even
guaranteed to be the name of the file in question. So it's not a good
idea to use window names for file system operations.
Have you looked at the BBEdit dictionary to see if it will give you the
path? You should always look at application dictionaries to find out
what Applescript terminology a given application supports.
To view an application's AppleScript dictionary:
1. Open Script Editor.
2. From the menu bar, choose File > Open Dictionary. A list of
applications will appear.
3. Select the application name in the list.
4. Click OK.
I don't have BBEdit; but I do have TextWrangler. In TextWrangler, if I
click "BBEdit Suite", and then select the "document" class to the right
of that, I see:
---
document n [inh. item] : every open document
ELEMENTS
contained by application.
PROPERTIES
modified (boolean, r/o) : does this document have unsaved changes?
modifiable (boolean, r/o) : can this document be modified?
modification date (date, r/o) : date and time this document was last
modified
name (text) : the title of the window (r/o if on disk is true)
on disk (boolean, r/o) : does this document exist on disk?
file (alias, r/o) : the disk file containing the document¹s data
creator type (type) : the OSType identifying the application that
created the item
window (window, r/o) : this document¹s window
---
So each document has a property called "file" that is an alias of the
file on disk. You'll find most often when you deal with files in
Applescript, you're actually dealing with an alias to the file. Aliases
are actually better than textual paths, because the operating system can
find the target file even if it's been moved or renamed since the alias
was obtained.
So I think you want something more like this:
-- begin script
tell application "TextWrangler"
set fileAlias to the first document's file
save the first document
close the first document
end tell
tell application "Textures"
activate
open fileAlias
end tell
-- end script
--
Send responses to the relevant news group rather than email to me.
E-mail sent to this address may be devoured by my very hungry SPAM
filter. Due to Google's refusal to prevent spammers from posting
messages through their servers, I often ignore posts from Google
Groups. Use a real news client if you want me to see your posts.
JR
>> Stay informed about: Applescript to open a file