1 Reply Latest reply on Jul 2, 2009 8:36 AM by FentonJones

    This applescript run fine in editor but won't compile in Filemaker??

    dmyers

      Title

      This applescript run fine in editor but won't compile in Filemaker??

      Post

      I wrote a applescript in the editor which runs fine but when I add it to a filemaker button or script using "preform applescript" it won't even compile?? What am I doing wrong? Seems like a filemaker bug to me??

       

      set myfile to (path to desktop folder as string) & "output.txt" as string

      try
          set ref_num to open for access myfile with write permission
      on error
          close access (myfile as alias)
          set ref_num to open for access myfile with write permission
      end try

      write "Hello World" to ref_num starting at 0 as string
      close access ref_num




        • 1. Re: This applescript run fine in editor but won't compile in Filemaker??
          FentonJones
            

          There are a few commands which run fine in vanilla AppleScript, but cause errors inside a FileMaker tell block; and anything that is not explicitly inside another app's tell block is inside FileMaker's when using Perform AppleScript. There's a pretty simple fix however, which is to wrap the incompatible commands inside another app's. For example:

           

          tell application "Finder"

          the read/write file commands

          end tell

           

          or, perhaps better, 

           

          tell application "System Events"

          commands

          end tell