What if an item in the list is (or contains) return?
for example:
set theList to {1,"2", "3", return, "red", "green", "blue"}
IndexOfItem("blue", theList)
==> 8
set theList to {1,"2", "3", return, "red
green", "blue"}
IndexOfItem("blue", theList)
==> 8
On Nov 17, 2006, at 6:08 PM, Emmanuel wrote:
> At 5:55 PM -0500 11/17/06, deivy petrescu wrote:
>> On Nov 17, 2006, at 15:54, Paul Berkowitz wrote:
>>
>>> Perhaps some of you can help out here, or direct me to somewhere
>>> I might
>>> find an answer, which will probably be in the shell script area.
>>>
>>
>> Paul;
>> I do not think you need shell.
>> I believe what I propose is a variation of Emmanuel's method,
>> which I could not fully remember.
>
> Here is the official version, where "tid" is a shortcut for "set
> AppleScript's text item delimiters to". That's slightly different
> from Deivy's method, which is excellent also.
>
> on IndexOfItem(theItem, theList)
> set od to tid(return)
> set theList to return & theList & return
> tid(od)
> try
> -1 + (count paragraphs of (text 1 thru (offset of (return &
> theItem & return) in theList) of theList))
> on error
> return 0
> end try
> end IndexOfItem
>
> Emmanuel
|