• 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
more coerce list to rec
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

more coerce list to rec


  • Subject: more coerce list to rec
  • From: Patrick Wynne <email@hidden>
  • Date: Tue, 5 Dec 2000 13:07:03 -0800 (PST)

A while ago, I asked for a way to coerce a list to a record and
received the following script in reply:

set aList to {"firstname", "Robert", "lastname", "Robertson"}
set aRec to {}
repeat with i from 1 to ((number of items in aList) / 2)
set l to item (i * 2 - 1) of aList
set v to item (i * 2) of aList
set bRec to run script ("set bRec to {" & l & ":\"" & v & "\"}")
set aRec to aRec & bRec
end repeat

Now, I'm trying to make it recursive so that if the list contains a
list, it is handled properly. By way of example:

{"firstname", "Robert", "lastname", "Robertson", "info", {"bday",
"10/24/67", "hair", "brown", "eyes", "green"}}

becomes

{firstname:"Robert", lastname:"Robertson", info:{bday:"10/24/67",
hair:"brown", eyes:"green"}}

My script skills don't seem to be up to the task, however. Any
suggestions?

Thanks,

Patrick Wynne
Yahoo! Shopping - Thousands of Stores. Millions of Products.
http://shopping.yahoo.com/


  • Prev by Date: Re: AppleScriptable Digital Camera?
  • Next by Date: How to retrieve items from list?
  • Previous by thread: Re: moving insertion point to beginning of text field
  • Next by thread: Re: more coerce list to rec
  • Index(es):
    • Date
    • Thread