MACSCRPT Archives

November 2006

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
David Livesay <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Fri, 17 Nov 2006 20:30:08 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (47 lines)
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

ATOM RSS1 RSS2