Will someone please remind me (I can’t find it in an extensive search) of a simple shell script or AppleScript method of discovering the version of AppleScript running on a machine?
get AppleScript version of (system info)
Note that ‘system info’ only appeared in 10.4.
Simplest solution is:
AppleScript's version
As hhas has already noted, some methods for getting the machine’s system or AppleScript version depend on the machine’s system or AppleScript version.
His solution is by far the simplest for getting a displayable version. However, what follows can save a script having to parse that. It works from at least OS 8.0 to the present day:
-- Based on research by Richard Morton in the early days of "Code Exchange".
-- The StandardAdditions's 'system attribute' used to be the Finder's 'computer' command.
tell application "Finder" to set ascv to (system attribute "ascv") mod 65536
-- For most practical purposes, scripts can compare this number
-- with some critical value worked out in advance.
-- But for display:
set hiDigit to ascv div 4096
if (hiDigit > 0) then
set hiDigit to hiDigit as string
else
set hiDigit to ""
end if
return hiDigit & ascv mod 4096 div 256 & "." & ascv mod 256 div 16 & "." & ascv mod 16
For the system version, change ‘(system attribute “ascv”) mod 65536’ to '(system attribute “sysv”).
Thank you Bruce, hhas & Nigel;
For my purposes, system info works, but Nigel’s will clearly test any version.
Follow-on: direct approaches don’t reveal the available system attributes (which are not listed in the Finder sdef either) how can I find out what they are? I note that Nigel’s "set ascv… " solution works in Tiger without the "tell application “Finder” to " prefix, but presumably was required for earlier system versions.
A
Note:
About system attributes. Try searching around for “gestalt”.
Apple:
“ Gestalt Manager Reference
“ [There’s another one on Apple, but I guess I didn’t bookmark it.]
Also, look at this thread: Where can I find info for System Attribute?
Thanks, Bruce.
Trashman has a long list of attributes but not the corresponding items being determined. All return numbers.
You must be a patient man, Bruce. Whenever I search the Developer Connection it seems like all of Apple is out to lunch.
You’d think that somewhere there’d be a table showing Name, Alias, Interpretation of number returned. Not so. I’ll devise other means, thanks.
A
I still haven’t found the one I’m looking for.
That’s right. You can get away without it if you’re only catering for OS X, but it’s needed if your script might find itself running in OS 9 or earlier. The command was transferred from the Finder to the StandardAdditions, and renamed from ‘computer’ to ‘system attribute’, at about the time of the transition to OS X. It uses the same event code, so there’s no need to recompile.