在 Filemaker 中运行时出现 AppleScript 错误

问题描述 投票:0回答:2

下面的 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

支持细节:

  • 在 FileMaker 安全设置下启用“允许 Apple 事件”
  • 我在 Filemaker 中的其他 AppleScripts 运行正常
  • FileMaker 在 MacOS 安全设置下具有“完整磁盘访问权限”
  • 版本:FileMaker Pro 19.6.3.302,MacOS Ventura 13.3.1
macos fonts applescript filemaker
2个回答
0
投票

不需要任何

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。)


0
投票

搞清楚了...不得不将 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
© www.soinside.com 2019 - 2024. All rights reserved.