0 Replies Latest reply on Apr 25, 2014 8:35 PM by tunesmith

    Sporadic Applescript Error opening Filemaker-generated files

    tunesmith

      Summary

      Sporadic Applescript Error opening Filemaker-generated files

      Product

      FileMaker Pro

      Version

      13.0v3

      Operating system version

      Mavericks 10.9.2

      Description of the issue

      I wrote a Filemaker script to write an mp3 (in a Container) to a filesystem file, via "Export Field Contents", and then launch an external player to play the mp3.

      You can see a much more detailed version of this bug report here:

      http://forums.filemaker.com/posts/673af4175a

      But here is a shorter version of the bug report that rules out some other behavior.

      Most of the time, the script works right.  But sometimes, I get the two error dialogs, "Finder got an error: AppleEvent handler failed.", and "Unknown Error: -10000".

      Here is the important bit.  When the error occurs in filemaker, I can duplicate the error by opening AppleScript Editor and running this script:

      set appPath to path to application "MPlayerX"
      set p to POSIX file "/private/var/folders/v1/f5_s4swx4bsf59wwwdv45g4w0000gn/T/S11/1-02 Blame It On My Youth.mp3"
      tell application "Finder" to open file p using appPath

      Then I try to run this script in AppleScript Editor:

      set appPath to path to application "MPlayerX"
      set p to POSIX file "/private/var/folders/v1/f5_s4swx4bsf59wwwdv45g4w0000gn/T/S11/"
      tell application "Finder" to open file p using appPath

      And I get this error:

      error "Finder got an error: Can’t make file \"Macintosh HD:private:var:folders:v1:f5_s4swx4bsf59wwwdv45g4w0000gn:T:S11:\" into type file." number -1700 from file "Macintosh HD:private:var:folders:v1:f5_s4swx4bsf59wwwdv45g4w0000gn:T:S11:" to file

      (Which is a completely expected error since I didn't append the filename to the file path).

      But then, I immediately go back to the first applescript editor, and run the original script, and it works.

      So it as if the second script "refreshed" some internal applescript catalog on the disk that enabled the first script to run...?  At any rate, at that point, my Filemaker script starts to work correctly again.  So I wonder if the bug is that Filemaker should be doing some sort of internal Applescript catalog refresh before it invokes "Perform Applescript", and it currently isn't refreshing it.  Or something.

      Steps to reproduce the problem

      Write a script like this in a layout that contains a container that contains an mp3:

      Set Variable [$path; Value:Get ( TemporaryPath )]
      Set Variable [$file; Value:GetAsText (Recordings::Song File)]
      Set Variable [$filename; Value:Middle ( $file ; Position ( $file ; “/“ ; 1 ;
          PatternCount ( $file ; “/“ ) ) + 1 ; 1000 )]
      Set Variable [$fullpath; Value:$path & $filename]
      Export Field Contents [Recordings::Song File; “$fullpath”]
      Set Variable [$script; Value:Let (
          thepath = Middle ( $fullpath  ; Position ( $fullpath ; "/" ; 1 ; 2 ) ; Length ( $fullpath) ) ;

      "
      set appPath to path to application \"MPlayerX\"  ¶
      set p to POSIX file " & Quote(thepath) & "¶
      tell application \"Finder\" to open file p using appPath"
      )]
      Show Custom Dialog [$script]
      Perform AppleScript [$script]

      Install the free MPlayerX app onto your Mac System.

      The script will mostly work, but sometimes not.

      Expected result

      The script should function by loading the mp3 into the other application and playing it.

      Actual result

      Filemaker *sometimes* yields the following errors in dialog boxes:

      "Finder got an error: AppleEvent handler failed.", and "Unknown Error: -10000"

      Exact text of any error message(s) that appear

      "Finder got an error: AppleEvent handler failed.", and "Unknown Error: -10000"

      Configuration information

      I have installed MPlayerX on my system.  It is free.

      Workaround

      If, after receiving that error, you run a different Applescript (b), like:

      set appPath to path to application "MPlayerX"
      set p to POSIX file "/private/var/folders/v1/f5_s4swx4bsf59wwwdv45g4w0000gn/T/S11/"
      tell application "Finder" to open file p using appPath

      Then you can go back to the originally generated Applescript (a), and it will function.  Note again that this behavior will happen even if the originally generated Applescript were put into AppleScript editor, and the following steps are taken:

      1) Run (a) in Applescript Editor - it will fail
      2) Run (b) in Applescript Editor - it will fail as expected
      3) Run (a) in Applescript Editor - it will succeed.

      This happens even if done in immediate succession, without switching back to Filemaker (which is running in the background).

      PS - The entire reason I am doing this is because I want to see elapsed minutes/seconds on my mp3 when I press play.  If you could add that to Filemaker (like how Bento has it, or how Filemaker Go has it), I could dump these applescripts.