System Attributes

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’

Nice work, Adam. Perhaps I could add this alternative to the vanilla collection (especially since it’s about 30+ faster). :wink:

AppleScript's version

I lot of interesting stuff there, Adam. Thanks. It’s certainly faster than quizzing System Profiler!

Two points with regard to your one-liners. Firstly, I think the “qtvv” and “qtim” adjustments should be ‘div 65536’ rather than ‘mod 65636’. That’s what gives the correct results on my machines, anyway.

tell ((system attribute "qtim") div 65536) to set vQT to (it mod 4096 div 256 & "." & it mod 256 div 16 & "." & it mod 16) as string -- same as "qtvv"

Secondly, since your string-building technique here starts with an integer, you’re actually performing a series of list coercions and concatenations, with the final list being coerced to string. This of course raises questions of efficiency and of text item delimiters. It would be safer to do such one-liners like this:

tell ((system attribute "qtvv") div 65536) to set vQT to (it mod 4096 div 256 as string) & "." & it mod 256 div 16 & "." & it mod 16

A few of the ‘system attribute’ parameters you mention appear to be fairly recent additions. The following just produce empty strings on my Jaguar machine: "ata ", “cpus”, “bclm”, “mclk”, “ramm”, “sys1”, “sys2”, and “sys3”. They all produce numbers on my Tiger machine, except for "ata ".

The shell scripts all work in Jaguar, except that the specifying parameter has no effect with “sw_vers”. You have to parse what you want from the three-paragraph result:

I read your postings and I found them most inspiring. Got hold of all documentation I could find about Gestalt management and read it. Now I’m wondering, where are the values for things related to monitor and display? VRAM, and so on? Or network? Is this something that doesn’t belong to Gestalt?
Since system profiler is displaying them, where does he gets them? Or he’s getting this kind of information in a totally different way? Can AS get them thru a do shell (wouldn’t like to itemize “system profile”)?

I sort of remember that MacOs X.2.xx was not displaying them completely, like VRAM wasn’t there, but Graphic card vendor was, if I remember correctly, but I couldn’t be sure.
I put together 216 flags, collecting them from various sources, mostly the Gestalt Manager Reference from developer. Couldn’t find anything about PCI/AGP. At least not so that I could recognize. Some things are indeed exotic (“otva”??) and I also can easily have misunderstood some of them.

I put up a filemaker with all flags and loaded a script that cycles all flags with an applescript for storing the result in a field. Just to be able to see what happens on my computer at a glance. Most of them are not set (134 of them aren’t set under my today’s configuration, for what this is worth as information.). This didn’t surprise me. But why not things like Machine Type “mach”, or file system "fs "?
And on it goes with questions.
Fascinating, it is.:rolleyes:


Model: PoweBook g4, 1500
AppleScript: 1.9.3
Browser: Safari 312.6
Operating System: Mac OS X (10.3.9)

Hi, orso;

For screens, see this link:

I know this series of posts goes way back, but it came up in my search to understand why running “return computer” in Script Editor on my MacPro/Yosemite would change itself automatically to “return system attribute”. Which would result in {“TMPDIR”, “SHELL”, “HOME”, “Apple_PubSub_Socket_Render”, “SSH_AUTH_SOCK”, “LOGNAME”, “PATH”, “XPC_SERVICE_NAME”, “COMMAND_MODE”, “USER”, “SECURITYSESSIONID”, “XPC_FLAGS”, “__CF_USER_TEXT_ENCODING”}

So I thought I’d share this script I made which incorporates many of the previous MacScripters’ suggestions with these other Environmental Variables into a tidy printout for reference.

If if you know of other Env Vars to add or test (certainly there are many), simply add them to either the ‘myEnvironmentalVariables’ list or the ‘shellScriptProbes’ list to include them in the result. I didn’t add an error handler so be careful what you add to the ‘shellScriptProbes’!

Thanks all!

set rprt to "MY ENVIRONMENTAL VARIABLES:" & return
-----------------Environmental Variables-----------------
set EnvironmentalVariables to {"ata ", "cbon", "cpus", "fbcv", "help", "kbd ", "qdrw", "bclm", "otra", "mclk", "ramm", "sys1", "sys2", "sys3", "cput", "bclk", "qtim", "qtvv"}
set EnvironmentalVariables to EnvironmentalVariables & (system attribute)
repeat with envVarName in EnvironmentalVariables
	set saEVN to system attribute envVarName
	set rprt to rprt & "" & envVarName & ":  	" & saEVN & return & return
end repeat
-----------------shell Script 'Probes'---------------------
set shellScriptProbes to {"sw_vers -productVersion", "uname -r", "machine", "whoami"}
repeat with ssProbs in shellScriptProbes
	set val to (do shell script ssProbs)
	set rprt to rprt & ssProbs & ":  	" & val & return & return
end repeat
return rprt

Model: Mac Pro, Yosemite
AppleScript: 2.7
Browser: Safari 601.2.7
Operating System: macOS 10.14

system attribute has been a StandardAdditions command since the introduction of OS X. But before that, it was a Finder command called computer. The token, «event fndrgstl», shows its Finder origins. The token was kept so that earlier scripts would continue to work. The term computer must still be hanging around in the StandardAdditions dictionary! :slight_smile: