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.

Featured Replies

One thing I really like about FMP is that you can specify a "calculation" for a perform AppleScript script step. However, this does leave something to be desired. Before each quote in the AS, you have to do a backslash, and at the end of each line, the paragraph symbol.

A problem I've had is that it's difficult to debug AppleScripts entered in FMP scripts. If the script is "static" -- i.e., you don't construct the script using various FM fields, etc. -- it's easy enough, because you can create the script in AppleScript editor, debug, and then copy and paste into FMP and enter the appropriate backslashes, etc.

However, this doesn't work well if the script is "dynamic," where you're creating the script in a calculation field based on various FM fields. I have found a pretty good solution, however.

First, create the script as a variable. Call it $script, for instance. So, the calculation field for the perform AppleScript would simply say $script.

Now, insert a halt script command just prior to the perform AS command in your FM script And prior to that command, create a text file where the contents of the file are $script. I use the Troi File plug-in, but there may be another way to do that.

At a minimum, with the Troi plug-in, you can open up the resulting text file in AppleScript editor, and execute it there. This is very beneficial, because the error handling is much better when executing an AS via the AS editor as opposed to directly through FM.

Let me know if I'm explaining myself clearly, and/or if you have any questions. I will say that this saved me at least an hour of debug time today -- it's a worthwhile thing to do for complicated AS execution through FM.

Provided you have FM Advanced – which for serious developing is a must anyway – then you can step through the script (or set a breakpoint) and retrieve the variable's calculated AppleScript from the Data Viewer to test it in the (Apple)Script Editor.

 

However, this does leave something to be desired. Before each quote in the AS, you have to do a backslash, and at the end of each line, the paragraph symbol.

 

An alternative is to use List() and Quote(), as in:

List (
"tell application " & Quote ( "MyApplication" ) ;
  "set my var to (some expression)" ;
"end"
)

However, this doesn't work well if the script is "dynamic," where you're creating the script in a calculation field based on various FM fields. I have found a pretty good solution, however.

 

A more typical approach is store the AS syntax in a preferences table in a text field and put placeholders in it where the FM content needs to go, something that can be easily targeted through a Substitute() call (like <<my_field_goes_here>>)

 

Then in your script, you retrieve the AS template, set it in a the variable, do the substitute.

As eos mentioned you don't need to output to a text file, you can just copy the value from the Data Viewer and plop it in the AS Script Editor.

 

This approach lets you make small tweaks to the AS template without having to find it in all the scripts where you use it.

AND since you store the template as text, there is no need whatsoever to escape all the quotes.

  • Author

Oh, both of these are great tips!  And, I so need to bite the bullet and move to FMP Advanced.  I'm a script writing fool.

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.