Re: Delete list item?
Re: Delete list item?
- Subject: Re: Delete list item?
- From: JollyRoger <email@hidden>
- Date: Wed, 24 Oct 2001 06:56:38 -0500
On 10/24/2001 1:20 AM, "Gvran Ehn" <email@hidden> wrote:
>
How do I delete a list item?
>
Is Akua Sweets the only way to go?
Nope. You can do it with plain AppleScript:
-- begin script
set myList to {"item 1", "item 2", "item3", "item 4"}
return RemoveListItem(1, myList)
on RemoveListItem(x, theList)
-- removes any item from a list
set x to (x as number)
if x < 1 then return theList
set numItems to count of items in theList
if numItems is 1 then return {}
if x > numItems then return theList
if x = 1 then
set newList to (items 2 thru -1 of theList)
else if x = numItems then
set newList to (items 1 thru -2 of theList)
else
set newList to (items 1 thru (x - 1) of theList) & (items (x + 1)
thru -1 of theList)
end if
return newList
end RemoveListItem
-- end script