Thanks Stefan for the quick reply. Know I understand how to determine the OS version from the number that system attribute “sysv” returns.
I also did some more digging and found this alternate solution using the “system info” command…
if (system version of (system info)) ≥ "10.5" then
display dialog "Running Leopard"
else
display dialog "Running Tiger or previous OS X version"
end if
I am not sure which is the ebst approach. It looks like he two approaches in your post and this approach above will all work equally well.
The annoying thing about methods for finding the system version is that most of them only work with certain system versions! system info, for instance, was introduced sometime between Jaguar and Tiger and is no good on systems earlier than its introduction. Before Mac OS X, system attribute, now in the StandardAdditions, used to be a Finder command called computer. Fortunately, they used the same underlying token, so if you wrote:
tell application "Finder" to set sysv to computer "sysv"
. the script compiled and worked on any system, although computer appeared as system attribute when viewed in OS X. This still works in Tiger.
If you simply want to differentiate between pre- and post-Leopard systems, you can pre-calculate that the “sysv” value for 10.5.0 is 4176 and use that in the script:
if ((system attribute "sysv") < 4176) then
-- Pre-Leopard
else
-- Leopard or later.
end if
I believe is was Tiger. You also couldn’t compare AppleScript version strings because considering numeric strings (also introduced in Tiger) was needed to properly compare “1.10” to “1.9”.
Yes, indeed ” even under AppleScript 1.8.3 in OS 9.2.2, as it turns out ” provided of course that the version solution isn’t used in that form in a tell block to something else that also has a version property. AppleScript’s version should be specified in that case.
The Standard Additions OSAX in AppleScript 1.8.3 also has the system attribute command. I can’t remember for sure now, but I believe it was implemented some time around OS 9.2 to increase compatibility with the emerging OS X. The OS 9.2.2 Finder still has the computer command in its Finder Basics suite.
The AppleScript version can also be got with a system attribute call. It’s not quite as fast as getting the version property directly from AppleScript, but processing the result is faster, so it works out about the same:
if ((system attribute "ascv") mod 65536 < 512) then
-- Pre-AppleScript 2.0.
else
-- AppleScript 2.0 or later.
end if