Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 5771 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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

Posted (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 by Guest
Fixed database name in AppleScript
Posted (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 by Guest

This topic is 5771 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.