如何在茄子的 属性 列表中动态插入键和值

How to insert key and value dynamically in a property list in eggplant

我已经获取了一个数据作为列表的列表(内部列表由 2 个值组成,例如 (name,sam)),现在我想读取每个内部列表的数据并添加第一个数据作为键并添加第二个数据作为 属性 列表的值。 例如。, ((name,sam),(date,fourth),(age,twenty)) = 列表列表

转换为 = (姓名:"sam",日期:"fourth",年龄:"twenty") = 属性 列表

我怎样才能做到这一点?

set excelRead to WorkBook(ResourcePath(fileName))
set readColumns to excelRead.Worksheet(sheetName)
set listOfData to cellRange("A:B") of readColumns
put (:) into newPlist
repeat with each item of listOfData
    put item 1 of it into key
    put item 2 of it into Value

end repeat

您只需将变量名放在方括号中,即可将其用作 属性 列表中的键:

put Value into newPlist.(key)
put Value into (key) of newPlist
put Value into newPlist's (key)

在此处的 SenseTalk 参考中:Referencing Property List Keys Using Variables