Jump to content
Server Maintenance This Week. ×

Quotation marks in a calculated AppleScript


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

Recommended Posts

Hello, the following is the essence of a problem I need to resolve. The code is AppleScript 

display dialog "Hello \"world\" " 

This code needs to run in FMP18 as a calculated applescript.

image.png.aead9334bd20459f7284dced4987a41f.png

I tried:

Perform AppleScript [display dialog \"Hello "world" \"] 

Perform AppleScript [display dialog \"Hello \""world"\" \"]

Perform AppleScript [display dialog \"Hello "\"world"\" \"]

Perform AppleScript [display dialog \"Hello \""world\"" \"]

and other permutations of 1 backslash and 2 quotation marks cause the calculation to be unsavable b/o error.

Perform AppleScript [display dialog \"Hello \"world\" \"] results in "A identifier can’t go after this “"”." -- after the calculation is saved. (Yes, "A identifier")

Perform AppleScript [display dialog \"Hello \"\"world\"\" \"] results in A “"” can’t go after this “"”. -- after the calculation is saved

and an error message of -2740.

Can anyone help me please?

Spoiler

 

 

image.png

Edited by Asu
added last line
Link to comment
Share on other sites

Enter this into FileMaker's calculation dialog ( in the 'Calculated AppleScript' dialog ).

"display dialog \"Hello \\\"world\\\"\""
  • " - opening quote required for text in FileMaker
  • display dialog - applescript command
  • \" - escaped quote mark reduces to a " when evaluated by FileMaker.
  • Hello - the string to appear inside the quoted string being fed to the AppleScript.
  • \\ - an escaped backward slash, that reduces to a single backward slash when evaluated by FileMaker.
  • \" - an escaped quote, that pairs with the previous backward slash, to open the string to pass to the AppleScript command.
  • world - string for inside the escaped quotes to feed into AppleScript.
  • \\ - an escaped backward slash, that reduces to a single backward slash when evaluated by FileMaker.
  • \" - an escaped quotation mark, that pairs with the previous backward slash, to form an escaped quotation mark to pass to AppleScript.
  • \" - another escaped quotation mark to close the string to pass into the AppleScript command.
  • " - closing quote required for text in FileMaker.

 

Visually it looks like this ( red characters reduce down when evaluated in FileMaker 😞

"display dialog \"Hello \\\"world\\\"\""

  • Like 1
Link to comment
Share on other sites

The easy way to solve such problems is to:

1. Enter the "native" version of your AppleScript into a text field:

display dialog "Hello \"world\" " 

2. Open the Data Viewer and enter:

Quote ( YourTable::Textfield )

3. Paste the result into your calculated AppleScript formula:

"display dialog \"Hello \\\"world\\\" \" "

 

Edited by comment
  • Like 2
Link to comment
Share on other sites

This topic is 1584 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.