Re: Converting Associative List to Record
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.