我需要使用applescript创建的记录列表。我正在尝试在Applescript中创建像哈希表这样的Java。
set grocery_list to {"milk", "butter", "eggs"}
set milk to {name:"Whole Milk", quantity:"1 Gallon", brand:"Newland Farms" }
set butter to {name:"Unsalted Butter", quantity:"1 pound", brand:"Land O Lakes"}
set eggs to {name:"Grade A jumbo eggs", quantity:"1 dozen", brand:"Farm Fresh"}
我需要一种可以通过以下方式创建此结构的方法:
遍历列表,获取单个商品,为每个商品获取品牌。
我试过了
say brand of (item 1 of grocery_list)
但这给了我一个错误
Can’t get brand of \"milk\"." number -1728 from brand of "milk"
任何建议的方式来实现这一目标?
提前致谢
最佳答案
你很亲密:
set milk to {|name|:"Whole Milk", quantity:"1 Gallon", brand:"Newland Farms"}
set butter to {|name|:"Unsalted Butter", quantity:"1 pound", brand:"Land O Lakes"}
set eggs to {|name|:"Grade A jumbo eggs", quantity:"1 dozen", brand:"Farm Fresh"}
set grocery_list to {milk, butter, eggs}
say brand of (item 1 of grocery_list)
关于applescript - 如何在applescript中创建记录列表,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18815921/