Re: Why save text item delimiters?
Re: Why save text item delimiters?
- Subject: Re: Why save text item delimiters?
- From: Steve Cunningham <email@hidden>
- Date: Mon, 16 Jun 2003 07:07:09 -0400
>
From: David Crowe <email@hidden>
>
One of the common aspects of all scripts that use the AppleScript
>
text item delimiters is that first they are saved, then set to the
>
desired value, then used, then restored.
>
>
In my mind, the first and last steps are a waste of time. If every
>
script always sets the delimiters to the desired value, then there
>
should be no need to restore them, and the code to save/restore is
>
just a waste.
>
From: Michelle Steiner <email@hidden>
>
Um, because some other part of the code had set them, and expects them
>
to be what they were set to. If you change them underneath, you should
>
put them back the way you found them.
>
>
If the main body of the script set them, and you change them within a
>
handler (subroutine), you had better restore them to what they were
>
before exiting the handler because the main body may still be using
>
them.
The constant saving and resetting has always seemed a bit over-defensive
to me too. Especially since you have to use the keyword phrase "text item
delimiters" instead of say "moof" :-)
It seems you could at least avoid the step of saving them by a
programming discipline of
(1) always setting them back to their default ({""}) value after changing
them and
(2) never calling another handler or script before setting them back
Not doing (1) would force you to reset them to their default values every
time you wanted to handle text using the default values, which would
probably be more effort than always resetting them after use.
(2) is just an issue of keeping track of things... which, of course, I
always loose track of :-)
So I guess the reason I still save and restore them is that that is the
only system which
*can't* go wrong :-). I think it was Vince Lombardi who, when asked why
his teams always kept the ball on the ground, responded "There are only
three things that can happen when you pass and two of them are bad".
Steve
_______________________________________________
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.