property-listeggplant

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 e.g., (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 . e.g., ((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

Solution

  • 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