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:
Paul Berkowitz <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Fri, 17 Nov 2006 15:27:20 -0800
Content-Type:
text/plain
Parts/Attachments:
text/plain (39 lines)
On 11/17/06 3:08 PM, "Emmanuel" <[log in to unmask]> 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

Ooh, that looks great. (Particularly because, yes, there will be a unique
instance in this list.) And very simple too. Also I'll already have it as
return-delimited text to begin with.

Thanks very much, Emmanuel. Very nice and straightforward.

-- 
Paul Berkowitz

ATOM RSS1 RSS2