Re: AsciiNumber & AsciiCharacter Handlers
Re: AsciiNumber & AsciiCharacter Handlers
- Subject: Re: AsciiNumber & AsciiCharacter Handlers
- From: Nigel Garvey <email@hidden>
- Date: Wed, 8 May 2002 14:14:41 +0100
Arthur J Knapp wrote on Tue, 07 May 2002 19:48:42 -0400:
>
> Date: Tue, 7 May 2002 15:41:50 -0400
>
> Subject: Re: AsciiNumber & AsciiCharacter Handlers
>
> From: Paul Skinner <email@hidden>
>
>
> Thanks to Arthur and has for the feedback!
>
>
>
> Arthur, I really liked the TIDs swapping tell block!
>
>
I know everyone is really sick of my continuous stream of praise for
>
Nigel Garvey, ...
[Yawn...]
>
... but I'm pretty sure that I first saw that particular type
>
of tids-tell block in some code of his. :)
The block in question being:
>
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}
>
end tell
I did in fact come up with the idea of applying the setting-by-list
technique to TID's about three or four years ago - though I don't suppose
I'm the first or the only person to have done so. The aim at the time was
to relieve the drudgery of having to type 'set AppleScript's text item
delimiters to ...' for several lines in a row. Later, I added the "tell
reference" idea so that the expression 'AppleScript's text item
delimiters' could be mostly abbreviated to 'contents'. (Another idea I
had - to set the 'beginning' of the delimiters to the new value and then
to reset them to their 'rest' afterwards - was roundly (and rightly) sat
upon by senior contributors to this group. ;-) )
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
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
end tell
... which is only about 12% slower than the conventional method.
NG
_______________________________________________
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.