Re: Two Questions
Re: Two Questions
- Subject: Re: Two Questions
- From: Nigel Garvey <email@hidden>
- Date: Wed, 14 Feb 2001 18:19:22 +0000
"Serge Belleudy-d'Espinose" wrote on Wed, 14 Feb 2001 15:21:03 +0100:
>
on remove_from_list (xItem, xList)
>
>
set {oldTID, AppleScript's text item delimiters} to +;
>
{AppleScript's text item delimiters, return}
>
>
set xList to "" & xList's items
>
>
set AppleScript's text item delimiters to xItem
>
set xList to xList's text items
>
>
set AppleScript's text item delimiters to oldTID
>
set xList to "" & xList's items
>
>
set AppleScript's text item delimiters to (return & return)
>
set xList to (xList's text items)
>
>
set AppleScript's text item delimiters to return
>
set xList to ("" & xList's items)'s text items
>
>
set AppleScript's text item delimiters to oldTID
>
>
return xList
>
>
end remove_from_list
>
>
(watch for +; as continuation char)
Serge,
Try adapting your handler this way:
on remove_from_list(xItem, xList)
set {oldTID, AppleScript's text item delimiters} to +;
{AppleScript's text item delimiters, return}
set xList to return & xList & return
set AppleScript's text item delimiters to return & xItem & return
set xList to xList's text items
set AppleScript's text item delimiters to return
set xList to ("" & xList)'s text items 2 thru -2
set AppleScript's text item delimiters to oldTID
return xList
end remove_from_list
Notice:
1) Both xList and the text item delimiter formed from xItem have a return
at each end (in case you want to remove the first or last items from the
list.)
2) I haven't written "xList's items", which is just a very inefficient
way of saying "xList".
3) The return list is all strings, so the method's only really good if
the original list is all strings too.
NG