How to pass data from a FileMaker field to an Applescript

喜欢而已 提交于 2019-12-11 19:39:21

问题


I need to delete a file off of my Cincinnati Laser from FileMaker. It gets it there via a FMScript that export field contents of a container to this location. So I know the file name and the path its all built in a calculation field on that record. But I don't know how to get that info into an Applescript using the FM12 "Perform AppleScript" script step When I hard code the path and file name (Shown Below) it works.

set xpath to "Titanium Brain:Users:smartin:Desktop:Laser:1512-clr-c.cnc"
tell application "Finder"
   delete file xpath
end tell

When I try to pass the field contents (Shown Below) it doesn't work.

set xpath to Laser::gCNCPath
tell application "Finder"
   delete file xpath
end tell

What am I missing?


回答1:


The problem with Perform AppleScript with calculations is always the managing of quotes and returns. Putting exactly the following into the 'Calculated Applescript' box of the 'Perform Applescript' script step should work for you:

"set xpath to " & Quote ( Laser::gCNCPath ) & ¶ &
"tell application \"Finder\"¶" &
   "delete file xpath¶" &
"end tell"

Honestly, though, the whole thing gets pretty ugly pretty quickly. If you have security locked down appropriately, I'd be more inclined to put the whole script into the Laser::gCNCPath field

set xpath to "Titanium Brain:Users:smartin:Desktop:Laser:1512-clr-c.cnc"
tell application "Finder"
    delete file xpath
end tell

And then, for the Perform Applescript, you only need to call the field:

Laser::gCNCPath



回答2:


Whenever I've needed to pass information from FileMaker to AppleScript (and I'll admit, it's been a while since I've done so), I've used the Native AppleScript field in the Perform AppleScript dialog box and used a global field to store the "parameter" that AppleScript needs and used AppleScript to pull that information.

set xpath to cell "gCNCPath" of layout "Laser" of current file -- double check this syntax, I'm working from memory
tell app "Finder" to delete file xpath


来源:https://stackoverflow.com/questions/18731522/how-to-pass-data-from-a-filemaker-field-to-an-applescript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!