下面的 AppleScript 代码(返回活动字体列表)在脚本编辑器中运行时运行良好,但在 FileMaker 中运行时返回错误。有什么想法可以修复它以便在 FileMaker 中调用时可以运行吗?
错误信息: 无法将 {NSFontManager 的 sharedFontManager 的 availableFontFamilies} 变成字符串类型。
use framework "AppKit"
tell application "FileMaker Pro"
set fontFamilyNames to (current application's NSFontManager's sharedFontManager's availableFontFamilies) as list
set AppleScript's text item delimiters to return
set fontList to every item of fontFamilyNames as string
set data cell "scriptResult" of table "globals" to fontList
end tell
支持细节:
不需要任何
tell
命令。当您从 FileMaker 中运行 AppleScript 时,整个脚本都包含在默认的tell application "FileMaker Pro"
块中。只有当您希望 another应用程序执行某些命令时,您才需要使用
tell
。
你应该能够简单地做到:
use framework "AppKit"
set fontFamilyNames to (current application's NSFontManager's sharedFontManager's availableFontFamilies) as list
set AppleScript's text item delimiters to return
set fontList to every item of fontFamilyNames as string
set cell "YourField" of table "YourTable" to fontList
(假设这是获取可用字体列表的最佳方式;我没有研究过,我看到有alternatives。)
搞清楚了...不得不将 tell 语句进一步向下移动。也将“FileMaker Pro”更改为“当前应用程序”以进行简化。
use framework "AppKit"
set fontFamilyNames to (current application's NSFontManager's sharedFontManager's availableFontFamilies) as list
set AppleScript's text item delimiters to return
set fontList to every item of fontFamilyNames as string
tell current application
set data cell "scriptResult" of table "globals" to fontList
end tell