• 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: coerce lists to records
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: coerce lists to records


  • Subject: Re: coerce lists to records
  • From: Bill Cheeseman <email@hidden>
  • Date: Fri, 17 Nov 2000 19:45:11 -0500

on 11/17/00 10:42 AM, Yosemite at email@hidden wrote:

> -- i am sure there are better ways but this does work
>
> 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

I think that is just a brilliant solution.

But it would be a little cleaner if you used the Repeat command's "by"
parameter. Then you could just use "+ 1" at the critical point, instead of
all that slow multiplication stuff.

Sort of like this (untested):

Repeat with i from 1 to length of aList by 2
set l to item i of aList
set v to item (i + 1) of aList

... And so on.

-
Bill Cheeseman, Quechee, Vermont <mailto:email@hidden>

The AppleScript Sourcebook
<http://www.AppleScriptSourcebook.com/>
Vermont Recipes-A Cocoa Cookbook
<http://www.stepwise.com/Articles/VermontRecipes/>


References: 
 >Re: coerce lists to records (From: Yosemite <email@hidden>)

  • Prev by Date: Re: [ANN] OSA Menu 1.2.3d2 TEST
  • Next by Date: Export as script
  • Previous by thread: Re: coerce lists to records
  • Next by thread: Re: coerce lists to records
  • Index(es):
    • Date
    • Thread