Search code examples
propertiesapplescriptbbedit

Can I find out if an AppleScript object has a certain property?


I'm attempting to script BBEdit to make me feel more at home in coming from TextMate. One thing I need to be able to do is see if an object I have a reference to has a particular property.

For instance:

tell application "BBEdit"
    tell front window
        get selected items
    end tell
end tell

This will succeed on a project window, but not on a disk browser window, because the latter does not have a 'selected items' property. How do I see if there is such a property in the object?

Please note: I know how to inspect an object in Script Editor (get properties) to see what properties it has, but I need to know at runtime what they are.


Solution

  • What about the class?

    tell application "BBEdit"
      if class of window 1 is disk browser window then
        # ...
      else
        # ...
      end if
    end tell