MACSCRPT Archives

November 2008

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Mark Lively <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Mon, 3 Nov 2008 11:40:21 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (40 lines)
On Nov 3, 2008, at 11:27 AM, Chuck Pelto wrote:

> I know that I should already know this, but it's been a  
> while....I've slept since last attempting this years ago....
>
> How does one insert data into the middle of an existing list?
>
> For instance, I have a list of items, including lists. I want to  
> insert an item into a new second position in the original list.
>
> Here's the original list....
>
> Set myList to {itemA, {itemM, x}, {itemP, y}}
>
> I have a new itemZ that I want to put in as the second item of  
> myList that displaces the current second and third items to be items  
> 3 and 4 of myList, with itemZ as the new second item.
>
> The new list should look like....
>
> {itemA, itemZ, {itemM, x}, {itemP, y}}
>
> Is there a simple call to do this? Or do I need to set up a complex  
> handler?

set alist to {1, {3}, 4, "Five", 6, {"7", 8, 9}}
set item2 to "2"

set alist to items 1 through 1 of alist & item2 & items 2 through -1  
of alist


Smile may be able to do it simply but the pure AS way is mighty easy  
itself.


-Mark
There are 3 types of people in this world.  Those who can count and  
those who count.

ATOM RSS1 RSS2