Re: I've changed the name of a file...
Re: I've changed the name of a file...
- Subject: Re: I've changed the name of a file...
- From: Richard 23 <email@hidden>
- Date: Fri, 3 Nov 2000 11:13:01 -0800
>
> I have to ask: Why?
>
>
OK, I get to answer my own question: Because yours worked and mine didn't
>
<blush>.
hahahaha! 8)
>
But even when I fix it:
oh. 8|
>
on GetName(filePath)
>
set oldDelims to AppleScript's text item delimiters
>
set AppleScript's text item delimiters to {":"}
>
if filePath ends with ":" then
>
set theName to text item -2 of filePath
>
else
>
set theName to text item -1 of filePath
>
end if
>
set AppleScript's text item delimiters to oldDelims
>
return theName
>
end GetName
>
the time stays about the same. So I'm still puzzled.
Well the silly |t/d| thing and the |?| have kind of an odd but brief
history.
About the |?| handler
My other primary languages are Perl and JavaScript.
Both have a ternary operator. (the question mark)
the syntax being:
expression ? evaluate if true : evaluate if false
sometimes its use (if it were available in AppleScript) would make the
script
seem less awkward (at least to me) rather than the multiline if-then-else
construct. Perhaps I should have omitted that from my posting.
I use it for stylistic reasons without regard for efficiency. I never
timed
its usage although since it evaluates both possible outcomes and adds a
handler call to boot it would certainly slow things up a bit.
About the |t/d| property
This came to me late one night when I was so tired of typing
"Applescript's
text item delimiters" over and over again that I thought I was going to
scream so I came up with an alternative. Again, this is a timesaver for
coding but probably isn't as efficient. I haven't gotten tired of having
to type "contents"...yet.
I have a script Benchmarking application which will be released once I
iron
out the rest of the kinks in Osax Manager. I'll run a few tests on both
the
|?| and |t/d| methods to see which is the more significant time dragger
and
perhaps reevaluate their usage.
I just wish there was a shorter way to set the tid property.
"text item delimiters" alone will work in scripts but don't know how safe
it is for forward compatibility and I've heard it doesn't work in
FaceSpan.
There you need to preface it with "AppleScript's".
Thanks for reminding me to benchmark the madness of my methods!
R23