Newbies Daniel Dow Posted December 11, 2012 Newbies Posted December 11, 2012 I'm having trouble running a calculated Applescript to set a field. I believe the problem is in the Applescript itself and not in the way I am using Filemaker. The script step is: Perform Applescript ["Set Id to do shell script " & Quote($Cut) & Quote ($tempFileName) & " set cell ID of current record to Id"] Where $cut = "cut -d , -f 1 " And $tempFileName = "/tmp/export.csv" The quotes are not part of the variables, this is just the string used to set them. (i.e. Set Variable[$Cut; Value:"cut -d , -f 1 "]) The error I get is: A """ can't go after this """. But I can't figure out where the bad quote is. I'm not really good with Applescript. Any help would be greatly appreciated. Thanks!
DanShockley Posted December 19, 2012 Posted December 19, 2012 Two things: First, I highly recommend building your AppleScript code into a FileMaker variable named, for example, $asCode. Then, Perform AppleScript by calc on that single variable. That makes it easier to debug. Second, the quoting around the string for the do shell script command needs to be all together, rather than two separate pieces. Here's what your script builds: Set Id to do shell script "cut -d , -f 1 ""/tmp/export.csv" set cell ID of current record to Id See how you have double quotes around the cut part and then new quotes around the file path? They need to be together. BUT, it is a good idea to quote filepaths using an AppleScript command that takes care of escaping anything as needed to run in a shell. You also need a line return before the "set cell" part of the script. Here's a fixed version of your calculation: Simple one (without using "quoted form of" - which really would be good to use, since not all paths are as simple and safe as yours here): "set Id to do shell script " & Quote ( $Cut & $tempFileName) & "¶" & "set cell ID of current record to Id" More carefully built calc that will work for any path: "set Id to do shell script " & Quote ( $Cut ) & " & quoted form of " & Quote ( $tempFileName) & "¶" & "set cell ID of current record to Id"
Recommended Posts
This topic is 4414 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