Re: Determining if a scripting addition is installed
Re: Determining if a scripting addition is installed
- Subject: Re: Determining if a scripting addition is installed
- From: kai <email@hidden>
- Date: Wed, 7 Sep 2005 00:35:27 +0100
On 6 Sep 2005, at 16:03, Matt Neuburg wrote:
try
run script "get the ticks"
on error -- evidently it isn't installed
set jons to choose file with prompt "Please find Jon's Commands:"
set sa to path to scripting additions from user domain
tell application "Finder" to duplicate jons to sa
try
tell me to «event ascrgdut»
end try
end try
display dialog (run script "get the ticks") -- 1974834
Sorry - but I'm still having difficulty seeing an advantage in using
text (in conjunction with the 'run script' command) over using raw code.
At some point, code needs to be tested to make sure it works as
expected. The only way I know how to do this properly is with the
required scripting addition installed. And if the software is
available, the relevant raw code(s) should be, too. (Although it's
usually not even necessary to determine the raw codes - only to make
sure the script works. As discussed already, raw codes are displayed
in place of English terms only if a script is opened on a machine
that doesn't have the required scripting additions installed.)
The argument that text is somehow more "portable" than raw code seems
to be based on a false premise. Sure, a script will compile if a
statement is pasted into it as a string - whether or not the pasted
term is currently available to AppleScript. However, the same is also
true of raw code.
Then there's the question of consistency of error codes. Using raw
codes, the error normally returned indicates that an AppleEvent was
not handled. On the other hand, 'run script' can produce a variety of
runtime or syntax errors (the latter, of course, normally being
signalled at compile time in a regular script).
For example, if the required scripting addition is not available,
'run script' returns errors such as:
--------
run script "the ticks" --> error number -2753 (OSAUndefinedVariable)
run script "sin 1" --> error number -2740 (OSASyntaxError)
run script "roots of {1.0, 2.0}" --> error number -1728
(errAENoSuchObject)
run script "move mouse {0,0}" --> error number -1708
(errAEEventNotHandled)
--------
- while, from the same commands entered as raw codes:
--------
«event JonstikC» --> error number -1708 (errAEEventNotHandled)
«event MATHSINE» 1 --> error number -1708 (errAEEventNotHandled)
«event SATIRoot» {1.0, 2.0} --> error number -1708
(errAEEventNotHandled)
«event CuSuCumm» {0, 0} --> error number -1708 (errAEEventNotHandled)
--------
Another concern I have is the potential for namespace conflicts -
especially if the target machine should have a number of third party
scripting additions installed (but not the one currently being tested
for). Surely such a risk is reduced significantly by using raw codes?
Finally, there are the speed considerations mentioned previously. In
comparisons here, testing for raw code is generally between 20 to 80
times faster than using the run script command (depending on the
specific term and whether or not the scripting addition is currently
available).
I may well be missing the point here, and I'm prepared to be
persuaded on this. However, although I find the run script command
very useful in a variety of situations, I still can't see why anyone
would recommend it over raw codes for this particular purpose.
---
kai
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden