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.
|