On 11/15/04 10:01 PM, "Scott Haneda" <[EMAIL PROTECTED]> wrote:

> on 11/15/04 9:44 PM, Paul Berkowitz at [EMAIL PROTECTED] wrote:
> 
>> Why do you assume that 1) AppleScript has a replace() function of some sort*
>> and 2) I don't know what I'm talking about?
> 
> I don't know what I have to do to not anger you Paul, like I said, it was to
> satisfy my curiosity.  I don't know Applescript at all and the times that I
> do have to use it, I thought that knowing why you chose this method may help
> me in the future, more or less, I was trying to learn something.
> 
> Of all the lists I am on, I ask a lot of questions, this is the only one I
> hesitate to ask questions on, for this very reason.  I see it on this list
> and only this list, I can guarantee I will get at the lest one email, as I
> have in the past, telling me to not let your replies get to me, as you are
> just "that way".  I actually thought to myself, should I reply to the
> previous email in plain text or HTML as I know Paul will probably yell at me
> for replying to script in plain text.  Then I thought that it is not
> pertinent to the question that the script maintains the ability to be run so
> I went for plain text.  Apparently my trepidation was misplaced.
> 
> Anyway, what I was looking for was a explanation of why you chose that
> method.  Now I know that AS does in fact not have a built in replace
> function.  
> 
> I wonder, how many people who read my email took it as me asking a simple
> question to try and understand something versus me implying Paul did
> something in an inefficient or less than ideal way?

How about asking "Does AppleScript not have a replace() function?", rather
than imply I didn't do the sensible thing? I'd be happy to reply "No, it
doesn't" in a straightforward manner. Why would you assume anything? Why ask
your question in a way that implies that I don't know what I'm talking
about? Why not just ask a straight question? The way you phrased your
question sets out to challenge the solution I gave as roundabout and less
good than the "obviously better" way. Why ask as a challenge, instead of
simply, when all I'm doing is trying to help someone?

AppleScript has lots of quirks. It's not a fully-featured programming
language. It was originally developed as a "poor man's scripting language" -
supposed to be easy. It also happens to be - so far - the only programming
language that can access applications. (Someone I know is creating a bridge
form application AppleEvents to Python precisely to avoid all the trouble
and compromises AppleScript brings with it. He is in the process of
succeeding.) So that's the language we have when accessing Entourage.

No, AppleScript does not have a replace() function. That's why I suggested
the method - text item delimiters - that works. As it happens, it's
extremely fast and efficient. It's one of the very best functions in the
AppleScript language. It's part of the language, not an addition. (There
used to be a bug that it would fail when there were over c. 4000 text items,
but that's been fixed in Panther.) Languages that have replace() functions
do precisely the same thing "under the hood" - in AppleScript you simply
have to spell it out - it takes 4 lines of code instead of 1. Not such a big
deal. And if you want to you can either write your own replace(what,
replacement) subroutine so that you only have to write one line of code
instead of 4 on each call, or you can use Satimage osax's 'change' command
(which comes complete with a full regex), or even use grep or sed or awk via
'do shell script' scripting addition if you prefer. Text items delimiters
are pretty neat and easy and don't involve a scripting addition call so
they're faster.

Sorry if I offended you by my tone. If you just asked in a straightforward
manner, rather than trying to look as if I'm being obtuse, you wouldn't get
my goat, and I'd answer simply myself, as I did answer the original
questioner.

-- 
Paul Berkowitz


-- 
To unsubscribe:                     
<mailto:[EMAIL PROTECTED]>
archives:       
<http://www.mail-archive.com/entourage-talk%40lists.letterrip.com/>
old-archive:       
<http://www.mail-archive.com/entourage-talk%40lists.boingo.com/>

Reply via email to