【问题标题】:How to insert key and value dynamically in a property list in eggplant如何在茄子的属性列表中动态插入键和值
【发布时间】:2019-08-18 22:17:27
【问题描述】:

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

转换为 = (name:"sam",date:"fourth",age:"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

【问题讨论】:

    标签: property-list eggplant


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 2015-04-30
      • 2011-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-23
      相关资源
      最近更新 更多