• 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
Re: Converting Associative List to Record
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Converting Associative List to Record


  • Subject: Re: Converting Associative List to Record
  • From: Joshua See <email@hidden>
  • Date: Thu, 6 Nov 2003 13:10:57 -0600

On Thursday, November 6, 2003, at 06:28 AM, Frank wrote:
As a new Applescript user I was wondering if there is an easy way to create records from associative list:

For example to convert the list:
{"name", "Frank", "city", "Brussels"}
to
{name: "frank", city: "Brussels"}
Somebody will no doubt point out a less messy technique or one more suited to your needs, but:

set x to {"name", "Frank", "city", "Brussels"}
set keylist to {"name", "city"}
set y to {}
repeat with i from 1 to length of x
if item i of x is in keylist then
-- single line here
set y to y & (do script "return {" & item i of x & ":\"" & item (i + 1) of x & "\"}")
end if
end repeat

--
Sincerely,
Joshua See


--
Sincerely,
Joshua See

Information Technology Services
University of Wisconsin at River Falls
410 South Third Street
River Falls, Wisconsin 54022-5001
Phone: (715)425-4357
Fax: (715)425-0645
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

References: 
 >Converting Associative List to Record (From: Frank <email@hidden>)

  • Prev by Date: Re: Time for a new AS list? (AB Selection, etc.)
  • Next by Date: Re: Volume index bug in Panther?
  • Previous by thread: Converting Associative List to Record
  • Next by thread: Re: Converting Associative List to Record
  • Index(es):
    • Date
    • Thread