Some time ago, Nigel Garvey posted a script for finding AppleScript version and System version that was derived from earlier work by Richard Morton.
Using that trick, I produced a few more as one-liners:
tell (system attribute "ascv") to set vAS to (it mod 4096 div 256 & "." & it mod 256 div 16 & "." & it mod 16) as string
tell (system attribute "sysv") to set vSys to ("1" & it mod 4096 div 256 & "." & it mod 256 div 16 & "." & it mod 16)
tell (system attribute "cpkr") to set vColorPk to (it mod 4096 div 256 & "." & it mod 256 div 16 & "." & it mod 16) as string
tell ((system attribute "qtvv") mod 65536) to set vQT to (it mod 4096 div 256 & "." & it mod 256 div 16 & "." & it mod 16) as string
tell ((system attribute "qtim") mod 65536) to set vQT to (it mod 4096 div 256 & "." & it mod 256 div 16 & "." & it mod 16) as string -- same as "qtvv"
For some other versions, just plain vanilla will do, and this straight-forward approach seems to work for any of the applications that have versions displayed in the Script Editor “Open Dictionary” window from the File Menu. Asking for the version will open the application to find out, of course.
-- Examples:
version of application "Script Editor"
version of application "System Events"
version of application "Foxfire" -- doesn't work. It does not declare its version to the system.
Interested in what I could find out beyond those two, I found two files buried deep in the system with a lot of such information in them: Gestalt.h, and Gestalt.r, both found in /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/Headers.
Here are some of the interesting ones (there are many more, but not all return something to a script):
system attribute "ata " -- uses ata drive
system attribute "cbon" -- carbon version
system attribute "cpus" -- number of CPUs running.
system attribute "fbcv" -- 4 if OS X, 3 if OS9 (find type)
system attribute "help" -- 0 if present
system attribute "kbd " -- keyboard type --> 34 = USB Pro Keyboard w/ F16 key Domestic (ANSI) Keyboard */
system attribute "qdrw" -- 47 this is the quickdraw attribute, not sure what it returns
system attribute "bclm" -- bus speed MHz.
system attribute "otra" -- 82 could you find out if user was connected?
system attribute "mclk" -- CPU clock in MHz (there's another that returns how fast it's actually running when not busy).
system attribute "ramm" -- RAM in MB
-- The next one is a combination of three to get the system version in a one-line vanilla applescript:
((system attribute "sys1") & "." & (system attribute "sys2") & "." & (system attribute "sys3")) as string
system attribute "cput" -- processor type; dual-core G5 = 324 or Ox144 -- see partial list below
system attribute "bclk" -- bus clock
There are a few shell script probes as well:
-- The following produces exactly the same result as the system attribute with a shell script approach
do shell script "sw_vers -productVersion" -- no decoding required
set Darwin to (do shell script "uname -r") -- the version of Darwin
set ProcType to do shell script "machine" -- the flavor of processor
This is what it says about processor versions:
CPU68000 0 /* Various 68k CPUs… /
CPU68010 1
CPU68020 2
CPU68030 3
CPU68040 4
CPU601 0x0101 / IBM 601 /
CPU603 0x0103
CPU604 0x0104
CPU603e 0x0106
CPU603ev 0x0107
CPU750 0x0108 / Also 740 - “G3” /
CPU604e 0x0109
CPU604ev 0x010A / Mach 5, 250Mhz and up /
CPUG4 0x010C / Max /
CPUG47450 0x0110 / Vger , Altivec */
CPUApollo 0x0111 /* Apollo , Altivec, G4 7455 /
CPUG47447 0x0112
CPU750FX 0x0120 / Sahara,G3 like thing /
CPU970 0x0139 / G5 /
CPU970FX 0x013C / another G5 */
/* x86 CPUs all start with 'i' in the high nybble */
CPU486 ‘i486’
CPUPentium ‘i586’
CPUPentiumPro ‘i5pr’
CPUPentiumII ‘i5ii’
CPUX86 ‘ixxx’
CPUPentium4 ‘i5iv’