Syntax 为什么可以';“我检索”;“目录”;Yojimbo中的一个注释项,但我可以检索;内容;?
Yojimbo的Applescript字典中的注释项定义如下:Syntax 为什么可以';“我检索”;“目录”;Yojimbo中的一个注释项,但我可以检索;内容;?,syntax,dictionary,applescript,Syntax,Dictionary,Applescript,Yojimbo的Applescript字典中的注释项定义如下: note item n [inh. database item] : A note item. elements contained by application. properties encrypted (boolean, r/o) : Is the note is encrypted? contents (text) : The contents of the note. syn content If
note item n [inh. database item] : A note item.
elements
contained by application.
properties
encrypted (boolean, r/o) : Is the note is encrypted?
contents (text) : The contents of the note. syn content
If this note is encrypted, the contents property is only readable
if permitted by the current security policies.
responds to
append, prepend.
为了导出我的数据,我一直在使用AppleScript,学习语言,等等,目前有:
tell application "Yojimbo"
repeat with EachNote in (note items in library)
display dialog (content of EachNote) as string
end repeat
end tell
让我困惑的是,尽管类定义了属性“contents”,但我必须使用“content”来检索内容。使用“内容”会导致此错误:
Can’t make «class YNot» id "A0C9E19E-3106-44F9-97A6-A1A74AD77948"
of application "Yojimbo" into type string.
我假设“syncontent”意味着它是同义词,因此我应该能够互换使用“content”和“contents”。但很明显,同义词起作用了,但原文却没有
而且,更简单地说,为什么必须将内容强制转换为字符串?如果我将对象上的属性(通过:(EachNote的属性)视为字符串
),则“contents”是一个双引号字符串,尽管我意识到这不一定“证明”它是字符串
我还是从AppleScript开始,所以如果我犯了一个n00bish错误,请随意拍打。对于其他发现类似困惑的人,我在这里找到了帮助: 所以所有的道具都归吉姆,因为他太棒了 基本要素:
- 对象的
与包含对象的变量的内容
不同内容
与其他属性不同,包含对象的变量返回的是对象,而不是对象的内容。其他属性按预期返回变量中对象的属性contents
- 这意味着,要获取变量内对象的内容,需要使用
变量内容的内容
- 事实证明,这是非常奇怪的。而
和var==var
,var==var的内容
,因此Applescript确实违反了本例中“contents”的标识原则。不过,它不会连锁这种效果,因此您不需要使用三层的var!=(contents of var)
内容(它的工作原理与两层相同)
也适用于对象,因此使用起来总是安全的var内容的内容
- 许多词典使用
作为content
的同义词,从而避免了整个问题。如果需要,使用var的contents
,它将像其他属性一样工作,总是返回对象的内容
,而不是对象内容