wintergreen Posted January 28, 2009 Posted January 28, 2009 Is there a simple way to return the result of a "calculated applescript" script step to the originating script? I appreciate this can be done by having the applescript itself write the result into a field on a layout, but i was hoping for something a bit more elegant
Fenton Posted January 29, 2009 Posted January 29, 2009 (edited) No, you've got to write it to a field. You do not have to be on the layout, if you specify the layout or table occurrence* name. It is easiest to do so with global fields, which do not care about "current record". *AppleScript uses the term "table", but it always means a FileMaker table occurrence (what you see on the relationship graph). Nothing can see the FileMaker "tables", which are better called "base tables", just to avoid confusion. Here's a funny little file I created to test various ways to set a field. [ Fixed database name in AppleScript. Oops! Never make cosmetic last-minute changes :-] AS_Tests2.zip Edited January 29, 2009 by Guest Fixed database name in AppleScript
wintergreen Posted January 29, 2009 Author Posted January 29, 2009 thanks that's really useful... A point for anyone else who's using this: The applescript refers to database "AStest"; this should be "AStests"
Fenton Posted January 29, 2009 Posted January 29, 2009 Oops! Last minute changes, as "ATests" seemed a better name for the file. Duh. Fixed it in the download file of my 1st post.
wintergreen Posted February 2, 2009 Author Posted February 2, 2009 (edited) Ok, this bit of code appended to the end of any fm applescript will capture the result: --applecript goes here set the_result to result set the_result to my asUnicodeString(the_result) set the_database to "my database" --change this to the database to write to set the_table to "my table" --change this to the table occurence to write to set the_field to "my field" --change this to the table occurence to write to tell me set field the_field of table the_table of database the_database to the_result end tell --from http://discussions.apple.com/thread.jspa?threadID=1105795 on asUnicodeString(a) local astid, NIL set astid to a reference to AppleScript's text item delimiters set NIL to "" as Unicode text try {«class AAAA»:a}'s «class BBBB» on error t -- t = "Can't get «class BBBB» of {«class AAAA»:a}" try set astid's contents to {"{«class AAAA»:"} set t to NIL & t's text items 2 thru -1 set astid's contents to {"}"} set t to NIL & t's text items 1 thru -2 set astid's contents to {""} return t -- t = a, which is in Unicode text on error errs number errn set astid's contents to {""} error errs number errn end try end try end asUnicodeString Edited February 2, 2009 by Guest
Recommended Posts
This topic is 6142 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now