Re: OS version questions
Re: OS version questions
- Subject: Re: OS version questions
- From: Nigel Garvey <email@hidden>
- Date: Sat, 19 Jul 2003 12:08:52 +0100
Paul Berkowitz wrote on Fri, 18 Jul 2003 18:28:57 -0700:
>
On 7/18/03 5:29 PM, "Nigel Garvey" <email@hidden>
>
wrote:
>
>
> Currently, if such a script is saved in 9.2.2 or 10.2, or as an
>
> X-compatible app in earlier versions of 9, it'll be viable in X and in
>
> any previous system where CarbonLib is installed and usable. However, it
>
> won't open in 8 if it contains a 'system attribute' command. If it's
>
> saved in 8, it'll only be viable in 8 or 9. Whether or not it'll actually
>
> *work* on any particular system depends on the individual peculiarities
>
> of the target software and the way the script's written. It's very rare
>
> for a script written for one of the earlier Finders to work in X without
>
> extra splints and rubber bands.
>
>
Whoa, Nigel! 'system attribute' is backwards compatible with the Finder's
>
'computer' command - which goes all the way back to System 7.0 or earlier, I
>
think. Someone please correct me if I'm wrong. It pre-dates CarbonLib by a
>
long way.
I mentioned CarbonLib to suggest why scripts saved as applications in OS
X also run in 8.6 and 9.2.2. That was however just an assumption. I
haven't uninstalled CarbonLib from my earlier systems to test this. From
Chris Nebel's reply, it seems I could have been wrong. Many apologies for
the reckless assertion if this is so.
>
So all you have to do is stick it into a Finder tell block. If you
>
are compiling and saving it in OS X, it will compile as:
>
>
tell application "Finder"
>
system attribute "sysv"
>
end tell
>
>
It will run in OS 7 and 8 and 9, but if you open the script there, you'll
>
see:
>
>
tell application "Finder"
>
computer "sysv"
>
end tell
Ah, right. And vice versa with regard to decompilation. Thanks Paul. Not
the most obvious thing in the world if you don't know about it, but at
least the work-round makes sense.
>
I use the following,similar to what Rob offered, but a lot shorter. I've
>
added Dave's display dialog. If you are running OS X or late OS 9.1/2,
>
'computer' will compile to 'system attribute'.
>
>
display dialog "You are running system version " & GetSystemVersion()
>
>
to GetSystemVersion()
>
>
tell application "Finder" to set hexNum to computer "sysv"
>
set {a, X} to {hexNum div 4096, hexNum mod 4096}
>
set {b, y} to {X div 256, X mod 256}
>
set {c, d} to {y div 16, y mod 16}
>
>
if a "0" then set b to "" & a & b
>
set OSvers to "" & b & "." & c & "." & d
>
>
return OSvers
>
>
end GetSystemVersion
Neat. :-) You've already pointed out in a follow-up that the 'if' line
should start 'if a is not...', but the "0" should also be a *numeric* 0,
otherwise the rest of the line will always be carried out. In 8.6, after
this correction, OSvers is returned as "8.6.0". As the ".0" on the end
doesn't suit my personal taste, here's a slight modification:
display dialog "You are running system version " & GetSystemVersion()
to GetSystemVersion()
tell application "Finder" to set hexNum to computer "sysv"
set {a, b, c} to {hexNum div 256, hexNum mod 256 div 16, hexNum mod
16}
if a > 15 then set a to {a div 16, a mod 16}
set OSvers to (a as string) & "." & b
if c is not 0 then set OSvers to OSvers & "." & c
return OSvers
end GetSystemVersion
NG
_______________________________________________
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.