Re: Why doesn't this cause an error?
Re: Why doesn't this cause an error?
- Subject: Re: Why doesn't this cause an error?
- From: Paul Skinner <email@hidden>
- Date: Tue, 24 Sep 2002 10:27:12 -0400
On Tuesday, September 24, 2002, at 04:59 AM, Mr Tea wrote:
This from Paul Berkowitz - dated 24-9-02 02.06 am:
If there's no offset, the offset indeed is 0, so that's the result
you get.
I'm not sure why you think that's worse than getting an error. You
just have
to set up an 'if the result = 0 then' condition to deal with it.
Did I say 'worse'? No. Unexpected is not equivalent to worse. I based
my
expectations on the notion that AS usually returns an error when you
ask it
to find something that isn't there.
True in many cases, so not an unreasonable assumption. But the
dictionary makes it clear that it's not so.
offset: Find one piece of text inside another (defined in:
StandardAdditions.osax)
offset
of Unicode text -- the source text to find the position of
in Unicode text -- the target text to search in
Result: integer -- the position of the source text in the target, or
0 if not found
On Monday, September 23, 2002, at 07:35 PM, Mr Tea wrote in reply to
Joseph Silverman:
Much of the information required to put together this script is freely
available in the Finder's scripting dictionary, and in the Standard
Additions scripting addition's dictionary, both of which you can read
by
opening them in a script editor.
Looking through these dictionaries is not always the most edifying
experience, but it's an essential task if you want to knock up your
own
scripts.
Nick
pp Mr Tea
; )
It seemed likely (to me, at least) that
this would also be the case when asking it to find the offset of
something
that isn't there.
SNIP
Generally speaking, if you can find some other way of doing something
other
than 'offset', do the other way.
Because... ?
It's slooooow. Breaking the string with TIDs and counting the resulting
items is quite a bit faster. The speed difference obviously increases
with string length.
Regards
N.
--
Paul Skinner
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.