• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Coercion of list to record
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: Coercion of list to record
      • From: Christopher Nebel <email@hidden>
  • Prev by Date: RE: Evaluating Double Byte
  • Next by Date: Coercion of list to record
  • Previous by thread: Scripting PowerPoint save command
  • Next by thread: Re: Coercion of list to record
  • Index(es):
    • Date
    • Thread