Re: Mac OS Version Sniffer
Re: Mac OS Version Sniffer
- Subject: Re: Mac OS Version Sniffer
- From: Brennan <email@hidden>
- Date: Tue, 22 Oct 2002 10:46:00 +0200
On Fri, 18 Oct 2002 21:33:32 +0100, Sean <email@hidden> wrote:
>
Under OS 9.2.1 it returns "9.2", under OS X 10.1.2 it returns "10.1.2",
>
and under OS X 10.2.1 it returns "10.2"
>
>
I haven't tested it under other versions of classic OS or Mac OS X but
>
since the Finder version tends to change with major system revisions,
>
it should be reasonably accurate.
This is only with the US versions of the MacOS. Other versions include a language code, such as "Z1-9.2" (International English). Needless to say this can't be coerced to a number, and (irritatingly) the language code contains a numeric character. It appears that the best heuristic should be based around the hyphen character.
If you trap a non-US system, you can filter out everything up to the hyphen like this:
tell application "Finder"
set vString to (version of application "Finder")
try
set v to vString as number
on error msg number n
if n is -1700 then -- can't coerce vString to number
set o to (offset of "-" in vString) + 1
set AppleScript's text item delimiters to ""
set vString to ((characters o thru end of vString) as string)
set v to vString as number
else
error number n
end if
end try
return v
end tell
I brought up this issue a few weeks back (11 Sept.) questioning whether the Finder version was the same as the system version, and whether the 'hyphen' heuristic was solid.
I didn't get a solid answer to the latter, but Kai Edwards sent me a script for Applescript 1.6 or later which uses the actual System version, rather than the Finder version.
try
tell application "Finder" to set {x, y} to {"", computer "sysv"}
on error number -1708 -- event not handled (no AS 1.6 commands in Classic)
set {x, y} to {"", 4096}
end try
repeat with n from 3 to 0 by -1
tell 16 ^ n to set {x, y} to {x & (y div it), y mod it}
end repeat
tell x as integer as string to set x to it's text 1 thru -3 & [NO BREAK]
"." & it's character -2 & "." & it's character -1
display dialog "Mac OS " & x & "." -- test
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.