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
-- Leopard or later.
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.
-- AppleScript 2.0 or later.