Finding the system language for ALL version's of Mac OS X?

Hi there,

To make my applescript back and forward compatible for multiple version’s of os x I would like to know if there is a way to find out in what version mac os x is running that would work in all version of mac os x, I’ve found multiple ways to do this that date down (or is it up to?) to 2003. but i haven’t found a 10.* wide way to do this. I’m not planning on making my script backwards compatible for 10.3 or .2 but for at least the last 3 versions (.5,.6 and .7) this would be really great!

Thanks in forward!

I actually thought i had to use terminal and did not search for a way to do this directly in applescript.
So this would work on all applescript versions?

Model: Macbook4.0
AppleScript: 10.7.4
Browser: Google Chrome something.something.something
Operating System: Mac OS X (10.7)

Yes.
This is my version. Same concept, but slightly more frugal with sending events - just one :wink:

set sysVersion to system version of (system info)
if sysVersion ≥ "10.6" then
	display dialog "Running Snow Leopard: " & sysVersion
else if sysVersion ≥ "10.5" then
	display dialog "Running Leopard: " & sysVersion
else if sysVersion ≥ "10.4" then
	display dialog "Running Tiger: " & sysVersion
else
	display alert "This must be Shady Pines..." message "I won't run on anything older than Tiger."
end if

(Note use of ‘greater than or equal to’ operator. Update code for newer OS, or change to exclude a newer one.)

Hi.

system info was introduced with Mac OS 10.4, so the method will work with all the system versions you say it’s for and with their respective AppleScript versions.

alastor933’s script needs to test for “10.7” and needn’t do the test for “10.4” since that’s the only possibilty left if the script hasn’t errored by then. Both scripts need to test for “10.8” or above. If there’s ever a Mac OS 10.10 or above, it’ll be necessary to do the string comparisons inside a considering numeric strings statement.

Hi,

a more reliable (and future-proof) way to retrieve the system version is


set systemVersion to (system attribute "sysv") mod 4096 div 16
-- Result: Tiger = 4, Leopard = 5, Snow Leopard = 6, Lion = 7, Mountain Lion = 8

or if you need both minor (10.x.0) or bug fix (10.0.x) values


tell (system attribute "sysv") mod 4096 to set {minorVersion, bugfixVersion} to {it div 16, it mod 16}

It’s almost past-proof too! :wink: system attribute “sysv” returns a binary-coded decimal representation of the system version:


tell (system attribute "sysv") to set sysvParts to {it div 4096, it mod 4096 div 256, it mod 256 div 16, it mod 16}
--> {1, 0, 6, 8} on my Snow Leopard (10.6.8) system.

Before system attribute became a Standard Additions command in Mac OS 9, the same token was used for the same purpose in the guise of a Finder command called computer, so the following worked with all system versions back to the introduction of AppleScript (in one of the subversions of Mac OS 7, I believe):

tell application "Finder"
	tell (computer "sysv") to set sysvParts to {it div 4096, it mod 4096 div 256, it mod 256 div 16, it mod 16}
end tell

computer still recompiles as system attribute in Snow Leopard!

The sub-subversion number in this binary-coded decimal system had to be regarded as hexadecimal when one of the AppleScript versions went up to 1.something.10 and beyond (system attribute “ascv”); but this wasn’t considered suitable when Tiger reached 10.4.10 and 10.4.11. On these two systems, the above “sysv” scripts return {1, 0, 4, 9}. Instead, those crazy folks at Apple introduced three new system attribute keys: “sys1”, “sys2”, and “sys3”:

set sysvParts to {system attribute "sys1", system attribute "sys2", system attribute "sys3"}
--> {10, 4, 11}, or {10, 6, 8} on my current system

So around that time, the method you had to use to determine the system version depended on the system version…