Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

get result from calculated applescript

Featured Replies

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

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

  • Author

thanks that's really useful...

A point for anyone else who's using this:

The applescript refers to database "AStest"; this should be "AStests"

Oops! Last minute changes, as "ATests" seemed a better name for the file. Duh. Fixed it in the download file of my 1st post.

  • Author

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

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.