简体   繁体   中英

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

I have fetched a data as list of list (inner list consists of 2 values eg, (name,sam)) , now I want to read the data of each inner list and add first data as key and add second data as a value of property list . eg, ((name,sam),(date,fourth),(age,twenty)) = list of lists

convert to = (name:"sam",date:"fourth",age:"twenty") = property list

How can i achieve this ?

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

You just need to put brackets around a variable name to use it as the key in a property list:

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

It's in the SenseTalk Reference here: Referencing Property List Keys Using Variables

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM