如何检查记录中的密钥是否存在?

Bil*_*ill 6 applescript

我发现如果我尝试访问记录中的字段,例如:

set track_album to (|Album| of t)
Run Code Online (Sandbox Code Playgroud)

并且该字段不存在,AppleScript会抛出错误.如何检查该字段是否存在?或者如何让它无声地失败?(无论哪种是最佳做法.)

jsp*_*cal 10

set track_album to album of (t & {album:default})
Run Code Online (Sandbox Code Playgroud)

它将被设置为相册(如果存在)或默认(如果不存在).

要么

try
album of t
on error -1728
default
end try
Run Code Online (Sandbox Code Playgroud)