• 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: Arrays in AppleScript ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Arrays in AppleScript ?


  • Subject: Re: Arrays in AppleScript ?
  • From: Paul Berkowitz <email@hidden>
  • Date: Wed, 28 Dec 2005 11:47:51 -0800
  • Thread-topic: Arrays in AppleScript ?

On 12/28/05 10:55 AM, "Michael Gmail" <email@hidden> wrote:

>> Worse, I don't even a have clue on how to add an entry to my array !
>
> set myArray to myArray & "d"
> -- > {"a", "b", "c", "d"}

Wrong. That only works here because there's an implicit coercion at work
turning "d" into {"d"} - this only works for text items and numbers; it
usually won't work for application objects. You need to concatenate two
lists to each other, like this:

set myArray to myArray & {"d"}
 -- > {"a", "b", "c", "d"}


But better (more efficient) is to

set end of myArray to "d"
 -- > {"a", "b", "c", "d"}


You can also set the beginning of a list. What's a lot trickier in
AppleScript than in some other languages is to insert a new element
somewhere in the middle.

--
Paul Berkowitz


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Arrays in AppleScript ?
      • From: Mark Lively <email@hidden>
References: 
 >Re: Arrays in AppleScript ? (From: Michael Gmail <email@hidden>)

  • Prev by Date: Re: Arrays in AppleScript ? [Solved]
  • Next by Date: Re: Arrays in AppleScript ?
  • Previous by thread: Re: Arrays in AppleScript ?
  • Next by thread: Re: Arrays in AppleScript ?
  • Index(es):
    • Date
    • Thread