I need a list of records created using applescript. I'm trying to create a Java like Hash Table in Applescript.
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"}
I need a way to create this structure in a way, that I can access the following:
Iterate through the list, get the individual items and for each item get the brand.
I tried this
say brand of (item 1 of grocery_list)
But this gave me an error
Can’t get brand of \"milk\"." number -1728 from brand of "milk"
Any recommended way to implement this ?
Thanks in advance
What Is AppleScript? AppleScript is a scripting language created by Apple. It allows users to directly control scriptable Macintosh applications, as well as parts of macOS itself.
You were close:
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With