Removing items from lists (again!)
Removing items from lists (again!)
- Subject: Removing items from lists (again!)
- From: Nigel Smith <email@hidden>
- Date: Thu, 22 Feb 2001 18:47:53 +0000
Last week we had handlers for removing an item from a list. All
the"iteration"-style handlers started with "if the first item is..." and
then started moving through.
But it seems as though AS is quite happy trying to get item 0 of a list
(though it sensibly fails trying to get the (length + 1) item) -- at least
on my system/AS version.
So how about this... Does it work for other people, or is my machine a
one-off :-)
____________________
on stripList(aList, anItem)
repeat with x from 1 to ((length of aList) - 1)
if item x of aList = anItem then
set aList to (items 1 thru (x - 1) of aList) & --<linebreak>
(items (x + 1) thru (length of aList) of aList)
exit repeat
end if
end repeat
if last item of aList = anItem then
set aList to reverse of rest of reverse of aList
end if
return aList
end stripList
____________________
Thanks,
Nigel