Re: Arrays in AppleScript ?
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