Coercion of list to record
Coercion of list to record
- Subject: Coercion of list to record
- From: "Robert R. Horning" <email@hidden>
- Date: Wed, 6 Feb 2008 13:19:31 -0700
Hi,
I wish to create a list of records at run-time. Both the name
(property) and value of each record in the list will come from an
Excel workbook. The names will equal the Excel column headers and
the values will be the ranges of the columns that include those
headers. I can extract the necessary data from the workbook, and can
create a list consisting of:
{(columnHeader1: range1), (columnHeader2: range2), ...},
where columnHeaders and ranges are variables containing the retrieved
data. But so far I've been unable to coerce the list of variables
containing strings into a list of records.
As a start, I've tried to use a technique found in Neuburg, M. (2006)
Applescript, the Definitive Guide, p253. Here's his code:
on listToRecord(L)
script myScript
return {<<class usrf>> :L} --(The << and >> are really guillemot
characters.)
end script
end listToRecord
set R to listToRecord({"name", "haha", "age", 51})
log |name| of R --Expect to get (*haha*), get (*name*). (Note
'pipe' symbols enclosing name in log statement.)
log age of R --Expect to get (*51*), get (*age*)
log nonsense of R --Expect to get error message, get (*nonsense*)
Has anyone a technique that will coerce a list of variables
containing strings into a list of records?
Thanks, Bob.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden