Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

penguine

macrumors newbie
Original poster
Sep 17, 2011
3
0
What is the difference between

1) open file object
and 2) open object
in applescript.
For example, I got an error "Can't make some data into the expected type." for the following code.

tell application "Finder"
set Xpath to "MacBookProHD:Users:tom:Music:"
set cueFile to (Xpath & "test.cue")
end tell
tell application "Toast Titanium"
activate
open cueFile
end tell

However, there is no error with

tell application "Toast Titanium"
activate
open file cueFile
end tell

For TextWrangler, either way works fine.
I'm confused.
 
I'm not an AppleScript guy, but here's what I think.

cueFile is not a file object, but a text object. Normally the specifier for the open verb should be a file object. It looks like TextWrangler can handle a text object as the specifier to its open verb, but Toast can't.

The form "open file cueFile" will create a file object from the cueFile text object before it is given to the open verb. This my thinking as to why it works with Toast.
 
I'm not an AppleScript guy, but here's what I think.

cueFile is not a file object, but a text object. Normally the specifier for the open verb should be a file object. It looks like TextWrangler can handle a text object as the specifier to its open verb, but Toast can't.

The form "open file cueFile" will create a file object from the cueFile text object before it is given to the open verb. This my thinking as to why it works with Toast.

Thanks. I was thinking exactly same way.
I also tried the following to wait cueFile has been generated.
I thought it should have worked, but it didn't.

tell application "Finder"
repeat while (file cueFile exists) = false
end repeat
end tell


Instested, the following line worked for me.
repeat while (cueFile exists) = false

So it doesn't look like cueFile itself is a text object.
 
What is the difference between

1) open file object
and 2) open object
in applescript.
...
For TextWrangler, either way works fine.
I'm confused.

Have you looked at the scripting dictionaries of the apps in question?

The exact meaning and modifiers of open is up to each specific app. For example, look at Finder's scripting dictionary, and compare to, say, Safari or Address Book.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.