Re: how to get os version?
Re: how to get os version?
- Subject: Re: how to get os version?
- From: Brennan <email@hidden>
- Date: Thu, 15 Nov 2001 20:52:12 +0100
Paul Berkowitz <email@hidden> wrote
>
Does anyone know what sort of data type 'version' is, and why there is such
>
a beast?
It may not make sense to US users, but for those of us running non-us systems, there's a very good reason for version to be a datatype. On my international english system (applescript's version) returns "Z1-1.4.3". ('Z1-' is a prefix used in version strings throughout the international English MacOS). Other language systems have their own prefices, for example Denmark is 'DK-'. This means that you should not assume that (version as string) will be comprised solely of numerical characters and periods (or 'full stops' for international English readers).
'applescript's version as real' gives me 1.43, which is much more useable. The version class, then, is a subclass of 'string' with special coercions to integer and real supported.
Unfortunately, 'version' in the context of the Finder is not of type 'version', but of type 'string', which is irritating if I want to make an internationalised script which checks the OS version.
tell application "Finder"
version
end tell
... returns "Z1-9.0"
To get a testable, international version code, you just strip away any characters up to and including the hyphen, but it would have been nice not to have to consider this. Not quite a bug, but certainly a design flaw. Maybe this is fixed in 9.1 or later.
(Can someone check? Everyone I know that has installed past 9.0.4 is complaining about stability in classic, so I'm staying in 9.0.4 until I feel secure enough to install any more Carbon cruft.).
Here's some internationally friendly OS version checking code.
tell application "Finder"
set v to (version as string)
if v contains "-" then
repeat while true
set c to (character 1 of v)
set v to ((characters 2 thru end of v) as string)
if c is "-" then
exit repeat
end if
end repeat
end if
end tell
-- returns "9.0", easily coerced to number, on this 'Z1-' system.
I hope US users will bear this issue in mind when checking OS version in their applescripts.
_____________
Brennan Young
Artist, Composer and Multimedia programmer
mailto:email@hidden
"History suggests very strongly that this revolution wont stop at 'a revolution in home entertainment' or a 'revolution in direct marketing.' Having tasted its power, there are bound to be people, outside the mainstream at present, who'll use the medium to promote much more radical agendas."
- Bob Hughes