4 Replies Latest reply on Apr 25, 2013 9:31 AM by VerneArase

    Problem with Applescript in FileMaker Pro Advanced 11.0v2

    jjackson+fm@pobox.com

      Summary

      Problem with Applescript in FileMaker Pro Advanced 11.0v2

      Product

      FileMaker Pro

      Version

      11.0v2

      Operating system version

      OS X 10.6.4

      Description of the issue

      There's a problem with the Applescript dictionary for FileMaker 11. Sending an ascr/gdte (get terminology) event to FMP appears to return the default Cocoa Scripting terminology, rather than FMP's actual dictionary. This may affect scripting FMP from AppleScript via Remote Apple Events.

      It showed up when I upgraded from version 10 to version 11. Scripts written in python that used the py-appscript library suddenly stopped working. Investigations showed that the dictionary being returned by FM was incorrect. Applescripts written with the Apple Script Editor aren't affected; and the Editor appears to have a correct dictionary.

      Steps to reproduce the problem

      Using py-appscript within the python interpreter, after opening the ASDictionary.app:

      import appscript
      fm11 = appscript.app('/Applications/FileMaker Pro 11 Advanced/FileMaker Pro Advanced.app')
      fm11.help('-t application')

      ===============================================================
      Help (-t application)

      Reference: app(u'/Applications/FileMaker Pro 11 Advanced/FileMaker Pro Advanced.app')

      ------------------------------------------------------------------------------
      Terminology for application class

      Class: application -- An application's top level scripting object.
      Plural:
        applications
      Inherits from:
        item (in Standard Suite)
      Properties:
        class_ (r/o) : type_class -- The class of the object.
        properties : record -- All of the object's properties.
        frontmost (r/o) : boolean -- Is this the frontmost (active) application?
        name (r/o) : unicode_text -- The name of the application.
        version (r/o) : unicode_text -- The version of the application.
      Elements:
        documents -- by name, index, relative, range, test
        windows -- by name, index, relative, range, test, id

      This is the default Cocoa Scripting dictionary, not the FMP one.

      Notice that there are no databases or menus listed as elements for the class 'application'. (There are other differences too, with the properties.) Having no database element accessible from the application object causes my scripts to fail.

      Expected result

      Doing the same for FileMaker 10, this is the dictionary I expected to see:

      Using py-appscript within the python interpreter, after opening the ASDictionary.app:

      import appscript
      fm10 = appscript.app('/Applications/FileMaker Pro 10 Advanced/FileMaker Pro Advanced.app')
      fm10.help('-t application')

      ==============================================================

      Help (-t application)

      Reference: app('/Applications/FileMaker Pro 10 Advanced/FileMaker Pro Advanced.app')

      ------------------------------------------------------------------------------
      Terminology for application class

      Class: application -- The application
        Plural:
          applications
        Properties:
          best_type (r/o) : type_class -- The best descriptor type
          class_ (r/o) : type_class -- The class
          default_type (r/o) : type_class -- The default descriptor type
          frontmost (r/o) : boolean -- Is this the frontmost application?
          name (r/o) : international_text -- The name of the application
          version (r/o) : version -- The version of the application
        Elements:
          documents -- by index, name
          windows -- by index, name
          databases -- by name, index
          menus -- by name, index

      ==============================================================

      app('/Applications/FileMaker Pro 10 Advanced/FileMaker Pro Advanced.app')

      Actual result

      See "Steps to reproduce" above.

      Exact text of any error message(s) that appear

      See "Steps to reproduce" above.

      Configuration information

      You need (in addition to FileMaker Pro 11 running on OS X), python, py-appscript, and the ASDictionary.app (available at http://appscript.sourceforge.net/tools.html) open.

      Workaround

      According to the developer of py-appscript (who suggested the error is occurring when sending a ascr/gdte (get terminology) event to FMP), this might work until the dictionary is fixed:

      As a workaround, use the dump function in appscript.terminology to export the FMP dictionary to a static module and pass that module when creating app objects, like this: app('FileMaker Pro', terms=fmp11terminologymodule). Make sure you run the dump command under 32-bit Python (use 'arch -i386' followed by the path to the python interpreter in the Python.framework bundle) as it uses OSAGetAppTerminology, which isn't present in OS X's 64-bit APIs.