set plist to (a:10, b:20, c:30, d:40)
set validKeys to (a, b, c, d)
repeat with each item of keys(Parameters)
if it is in validKeys then
set command to "set" && it && "to plist." & it
do command
else
log warning "extra key,value ( " & it & ", " & plist.it &") ignored because not expected"
end if
end repeat
put a -- outputs 10
put b -- outputs 20
That’s a good solution, and shows an appropriate use of the ‘do’ command to construct a command using a dynamic variable name.
In this case, since it appears that you want a selected set of the properties rather than all of them, here’s a simpler approach (taking advantage of SenseTalk’s multiple assignment and ability to access a list of properties at once) that might also suit your needs:
set plist to (a:10, b:20, c:30, d:40)
set (a,b,c,d) to plist.(a,b,c,d)
put a,b,c,d