在我的可编写脚本的应用程序中,其中一个属性是命名记录类型,并且该记录类型也已在 sdef 中声明(名为“自定义记录”)。
我可以这样获取记录:
get owner of anElement
--> {pool:"test", position:2}
我也可以像这样成功测试它:
set target to {pool:"test", position:2}
if owner of anElement = target then
-- found!
但我不能在 who 子句中使用它:
get allElements whose owner = target
--> {}
我也无法在测试中使用缺失值
:
get allElements whose owner = missing value
--> error number -1700 from missing value to custom record
这是 AppleScript 的预期行为吗?即它是否无法处理 who 子句中的记录?
还是我做错了什么?到目前为止,我还没有实现任何强制处理程序或特殊记录处理程序,因为没有任何迹象表明我需要它们。
另外,请参阅我的相关问题:Cocoa Scripting: Returning "null" vs. "missing value"
最佳答案
简短回答:这是预期的行为。
whose 子句仅适用于 element
引用类型(具有对象说明符的类),但不适用于记录类型和自定义列表。
即使是 Finder 的 selection
属性也无法通过 who 子句进行过滤。
关于macos - AppleScript:将 "whose"与记录值一起使用不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36922783/