Re: how to get os version?
Re: how to get os version?
- Subject: Re: how to get os version?
- From: Paul Berkowitz <email@hidden>
- Date: Thu, 15 Nov 2001 06:43:10 -0800
On 11/15/01 5:58 AM, "AppleScripter" <email@hidden> wrote:
>
You can get almost anything you need by asking for the version.
>
>
tell app "Finder"
>
display dialog the version
>
end tell
>
>
display dialog applescript's version
>
>
Both of those will give you what you need to know relevant to AS.
Does anyone know what sort of data type 'version' is, and why there is such
a beast? I note with interest that the data type for 'version' property in
'application' class of the Standard Suite in the current Dictionary of the
Finder is 'Unicode text'. Thus you can do;
tell application "Finder"
set theVersion to version
end tell
set x to character 3 of theVersion
--> "."
More usefully, you can set AppleScript's text item delimiters to {"."} to
get
tell application "Finder"
set theVersion to version
end tell
set AppleScript's text item delimiters to {""}
set shortVersion to text item 1 of theVersion & "." & text item 2 of
theVersion
set AppleScript's text item delimiters to {""}
set shortVersion to shortVersion as real
if shortVersion < 10.0 then
-- do Classic stuff
else
--do OS X stuff
end if
I had just tried this yesterday with Microsoft Entourage and came up short
with quite a bump. Although 'version' of the current Entourage 2001 results
in
"9.0.1"
complete with quotation marks, (and a certain other version I have access to
comes out as "10.0.0.")
trying to get character 3 of this, or getting text item 1 of it, fails.
--> Error: Can't get character 3 of "9.0.1"
That's because it's not a string, nor Unicode text. (Virtually all of
Entourage's actual text fields are in fact Unicode now.) It's 'version' data
type, whatever that may be.
Fortunately 'version' will coerce to string easily, so
tell application "Microsoft Entourage"
set theVersion to version as string
end tell
--rest of script works
Presumably this 'version' data type, given for the implementation of
'version' property of 'application' in the Standard Suite, is inherited from
a much earlier (slightly earlier?) SDK of AppleScript. I'll report it to the
Entourage team as something that should be fixed but I'd appreciate knowing
a few more details of what this is all about in the first place.
Chris? Jon? What was 'version' when it was at home?
--
Paul Berkowitz