applescript question

Discussion in 'Mac Programming' started by penguine, Sep 17, 2011.

  1. penguine macrumors newbie

    Joined:
    Sep 17, 2011
    #1
    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.
     
  2. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #2
    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.
     
  3. penguine thread starter macrumors newbie

    Joined:
    Sep 17, 2011
    #3
    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.
     
  4. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #4
    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.
     

Share This Page