3 Replies Latest reply on Jul 15, 2009 11:59 AM by edusouza

    Applescript and Filemaker -- another possible bug

    edusouza

      Summary

      Applescript and Filemaker -- another possible bug

      Description of the issue

      Hello, I'm using FileMaker Pro Advanced version 10.0v1 running on an iMac PPC G5 single with 2 GB RAM and OS X Tiger (10.4.11 85165). I'm developing a solution that uses several AppleScripts to perform some external routines. One of these actually saves the content of the clipboard -- data previously copied by FileMaker -- into a faceless TextEdit document. I first tested the script with Script Editor, and it worked without any problems; yet, when I tried to accomplish the same task using the "Perform AppleScript" step, FileMaker returned an error.Below, I place the codes. FileMaker Script is fairly simple:Allow User Abort [off]Copy [Select; field's name]Perform Applescript [FileMaker will neither allow the AppleScript to be inserted as "Native" nor run it as "Calculated Script"  Now, the AppleScript:set thisText to the clipboardset curdate to (current date) as stringset logMessage to "Login: " & tab & curdate & returnset completeLog to logMessage & return & thisTextset output_file to (path to desktop as text) & "nossolog.txt"try     open for access file output_file with write permission     write completeLog & return to file output_file starting at eof     close access file output_fileon error     close access file output_fileend try The message FileMaker Pro Advanced returned when I tried to insert this code as "native" Applescript was: "Expected End of Line, etc, but found Identifier", followed by highlighting the variable "completeLog" on line 8. I then tried a simple workaround: I inserted the AppleScript into a Global Text Field and placed this field into the scripstep as a "calculated script". The script did not work as well; however, this time FileMaker returned two messages: the "Expected ... Identifier" one, followed by "Unknown Error: - 2741".On a final note: I'm using Script Editor version 2.1.2 (81.1) running AppleScript 1.10.7.I hope this may have helped to improve FileMaker. Regards,   Eduardo Souza  

        • 1. Re: Applescript and Filemaker -- another possible bug
          comment_1
             I guess you need to enclose your AppleScript within a "tell <some application>" block - because when you run it from within Filemaker, it's all within an implicit "tell Filemaker" block.
          • 2. Re: Applescript and Filemaker -- another possible bug
            PeterWagemans
              

            Indeed. The Finder wil do nicely.

             

            • 3. Re: Applescript and Filemaker -- another possible bug
              edusouza
                

              Hello, 

               


              comment wrote:
              I guess you need to enclose your AppleScript within a "tell <some application>" block - because when you run it from within Filemaker, it's all within an implicit "tell Filemaker" block.

               

               

              Comment, you're absolutely right. When running the script from the Script Editor, the AppleScript engine "assumes" it is a finder-related script, and performs it flawlessly. But this will not happen when the same script is run from within another application.

              So here is the new AppleScript:

               

              set thisText to the clipboard

              set curdate to (current date) as string

              set logMessage to "Login: " & tab & curdate & return

              set completeLog to logMessage & return & thisTextset

              output_file to (path to desktop as text) & "nossolog.txt"

              tell application "Finder"

                   try

                        open for access file output_file with write permission

                        write completeLog & return to file output_file starting at eof

                        close access file output_file

                   on error

                        close access file output_file

                   end try

              end tell

              Perhaps I should change the thread's title to "Eduardo -- another possible bug?" :)

              Thanks a lot for your time and help and happy FileMaking.

               

               E*