Another suggestion ...
The original question asks how to convert a list to a record. A
better solution might be not to waste time and effort constructing
the list, but to construct the record directly, item by item. The
original list was ...
set aRecord to (run script ("{" & "fSource" & ":" & "PicName" & "}"))
set aRecord to aRecord & (run script ("{" & "fObjStyle" & ":" &
"[Basic Graphics Frame]" & "}"))
set aRecord to aRecord & (run script ("{" & "fWidth" & ":" & "12p6" &
"}"))
set aRecord to aRecord & (run script ("{" & "fHeight" & ":" & "9p3" &
"}"))
You are probably building the list within a loop, so all you need is ...
repeat something in somethingelse
-- get next record item name = itemName
-- get next record item value = itemValue
set aRecord to aRecord & (run script ("{" & itemName & ":" &
itemValue & "}"))
end repeat
On Jun 23, 2007, at 1:58 PM, Michelle Steiner wrote:
On Jun 23, 2007, at 11:00 AM, Luther Fuller wrote:
on run
set aList to {"recName", 5}
set scriptText to "{" & (item 1 of aList) & ":" & (item 2 of
aList) & "}"
set aRec to run script scriptText
display dialog (recName of aRec)
end run
And here is a generic solution:
on run
set scriptText to "{"
set aList to {"recName", 5, "rec2", 2, "rec3", "\"third record\"",
"rec4", true, "rec5", false}
repeat with i from 1 to (count aList) by 2
set scriptText to scriptText & (item i of aList) & ":" & (item (i
+ 1) of aList) & ","
end repeat
set scriptText to text 1 through -2 of scriptText
set scriptText to scriptText & "}"
set aRec to run script scriptText
end run
-- Michelle
--
"The past is like a foreign country. They do things differently
there." --Leslie Poles Hartley