Re: AsciiNumber & AsciiCharacter Handlers
Re: AsciiNumber & AsciiCharacter Handlers
- Subject: Re: AsciiNumber & AsciiCharacter Handlers
- From: Arthur J Knapp <email@hidden>
- Date: Wed, 08 May 2002 12:36:23 -0400
>
Subject: Re: AsciiNumber & AsciiCharacter Handlers
>
Date: Wed, 8 May 2002 14:14:41 +0100
>
From: Nigel Garvey <email@hidden>
>
>> Arthur, I really liked the TIDs swapping tell block!
>
Arthur J Knapp wrote on Tue, 07 May 2002 19:48:42 -0400:
>
> I know everyone is really sick of my continuous stream of praise for
>
> Nigel Garvey, ...
>
[Yawn...]
Garvey? Wait a minute, I meant Shane... ;-)
>
> tell (a reference to text item delimiters)
>
> set {o, contents} to {contents, c}
>
> set {i, contents} to {my kStr256's text item 1's length, o}
>
It's very inefficient code though and the above snippet takes about twice
>
as long to execute as its conventional counterpart. This is because of
>
the overheads involved behind the scenes in setting up the lists and the
>
reference. Nowadays, I tend to avoid both ideas. But there may be some
>
merit - if the TID's are changed a lot during the course of a script - in
>
having the reference precompiled as a property:
>
>
property TIDref : a reference to AppleScript's text item delimiters
Pre-compiling references? Where ever did you get that idea? ;-)
>
So wherever you needed it, you could type something like this:
>
>
tell TIDref
>
set o to contents
>
set contents to c
>
set i to (count kStr256's text item 1)
>
set contents to o
>
... which is only about 12% slower than the conventional method.
Multiple use of tids-based processing should always seek to perform
only one save and one restore operation, ie:
-- Not so good:
--
repeat (a million billion) times
ProcessCharacter(c)
[snip]
on ProcessCharacter(c)
set oldDelim to tids
set tids to something else
[snip]
set tids to oldDelim
-- Much better:
--
set oldDelim to tids
repeat (a million billion) times
ProcessCharacterIgnoringTids(c)
end
set tids to oldDelim
on ProcessCharacterIgnoringTids(c)
set tids to something else
return whatever
We need to revisit Nigel's old suggestion that a future update of
AppleScript should include an "inline" tids expression:
get text items of whatever using text item delimiters "whatever"
using text item delimiters "whatever"
get text items of whatever
end
I am still at least 98 percent behind this idea. ;-)
{ Arthur J. Knapp, of <
http://www.STELLARViSIONs.com>
<
mailto:email@hidden>
try
<
http://homepage.mac.com/kshook/applescript.html>
on error number -128
end try
}
_______________________________________________
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.