RE: Coercion of list to record
RE: Coercion of list to record
- Subject: RE: Coercion of list to record
- From: Olof Hellman <email@hidden>
- Date: Wed, 6 Feb 2008 12:59:22 -0800
- Acceptlanguage: en-US
- Thread-topic: Coercion of list to record
Robert -
A good place to start is our 2001 thread on this topic:
http://lists.apple.com/archives/applescript-users/2001/Dec/msg00430.html
http://lists.apple.com/archives/applescript-users/2001/Dec/msg00429.html
http://lists.apple.com/archives/applescript-users/2001/Dec/msg00482.html
http://lists.apple.com/archives/applescript-users/2001/Dec/msg00479.html
http://lists.apple.com/archives/applescript-users/2001/Dec/msg00499.html
http://lists.apple.com/archives/applescript-users/2001/Dec/msg00556.html
http://lists.apple.com/archives/applescript-users/2001/Dec/msg00634.html
http://lists.apple.com/archives/applescript-users/2001/Dec/msg00626.html
http://lists.apple.com/archives/applescript-users/2001/Dec/msg00627.html
- Olof
-----Original Message-----
From: applescript-users-bounces+olofh=email@hidden [mailto:applescript-users-bounces+olofh=email@hidden] On Behalf Of Robert R. Horning
Sent: Wednesday, February 06, 2008 12:24 PM
To: email@hidden
Subject: Coercion of list to record
Hi,
I wish to create a list of records at run-time under Tiger. 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
_______________________________________________
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