[comp.sys.mac.programmer] Testing for System 7

mrd@runx.oz.au (Malcolm Davidson) (06/27/91)

How do I test for the presence of system 7? I dont have access to
IM VI as yet.

Thanks in advance.
-- 
Malcolm Davidson, CSIRO Division of Mineral and Process Engineering,
Lucas Heights Research Laboratories, Private Bag 7, Menai, N.S.W. 2234 Australia
CSIRO               |    mrd@mpe67.dmpe.csiro.au
RUNX UNIX TIMESHARE |    mrd@runxtsa.runx.oz.au

philipc@runx.oz.au (Philip Craig) (06/28/91)

In article <1991Jun27.125511.19565@runx.oz.au> mrd@runx.oz.au (Malcolm Davidson) writes:
>How do I test for the presence of system 7? I dont have access to
>IM VI as yet.
Xref: munnari.OZ.AU comp.sys.mac.programmer:25763

Try the Gestalt call, which is of course documented in Inside Mac VI. Note that
Apple recommends using the Gestalt call to check for particular features, 
e.g. The Help Manager, rather than system versions.

If you can't get access to Inside Mac VI, SysEnvirons will tell you the
system version. This is documented in Spinside Macintosh Chapter 2, or
Inside Macintosh Volume V.
-- 
| Philip Craig          | ACSnet,Ean,CSnet: philipc@runxtsa.runx.oz.au         |
| RUNX Unix Timeshare   | Arpa:  philipc%runxtsa.runx.oz.au@UUNET.UU.NET       |
| Wahroonga  NSW  2076  | Janet: philipc%runxtsa.runx.oz.au@UK.AC.UKC          |
| Australia             | UUCP:{uunet,mcvax}!munnari!runxtsa.runx.oz.au!philipc|

dorner@pequod.cso.uiuc.edu (Steve Dorner) (06/29/91)

>How do I test for the presence of system 7? I dont have access to IM VI.

#ifdef ERRANT_PEDANTRY

You shouldn't test for system 7, you should test for the capability you're
interested in.

#else

/* this ought to work even without fancy system 7 glue or routines */
Boolean Is7(void)
{
  SysEnvRec env;

  SysEnvirons(ENVIRONS_VERSION,&env);
  return(env.systemVersion >= 0x0700);
}

#endif
--
Steve Dorner, U of Illinois Computing Services Office
Internet: s-dorner@uiuc.edu  UUCP: uunet!uiucuxc!uiuc.edu!s-dorner

nerm@Apple.COM (Dean Yu) (06/29/91)

In article <1991Jun27.125511.19565@runx.oz.au> mrd@runx.oz.au (Malcolm Davidson) writes:
>How do I test for the presence of system 7? I dont have access to
>IM VI as yet.
>

  Oh boy, oh boy, I get to use a party line.  You should never assume the 
presence of a feature based on the version number of system software.  You 
should check for the presence of each feature specifically by using the _Gestalt
function.

  -- Dean Yu
     Blue Meanie, Negative Ethnic Role Model, Window Cleaner, etc.
     Apple Computer, Inc.
     blah blah blah blah...

davids@mondo.engin.umich.edu (David Snearline) (06/29/91)

In article <54449@apple.Apple.COM> nerm@Apple.COM (Dean Yu) writes:
>In article <1991Jun27.125511.19565@runx.oz.au> mrd@runx.oz.au (Malcolm Davidson) writes:
>>How do I test for the presence of system 7? I dont have access to
>>IM VI as yet.
>>
>
>  Oh boy, oh boy, I get to use a party line.  You should never assume the 
>presence of a feature based on the version number of system software.  You 
>should check for the presence of each feature specifically by using the _Gestalt
>function.
>
>  -- Dean Yu
>     Blue Meanie, Negative Ethnic Role Model, Window Cleaner, etc.
>     Apple Computer, Inc.
>     blah blah blah blah...

Except that you would have to check the version of the system to see
if _Gestalt exists...  :-)

--
David Snearline
davids@mondo.engin.umich.edu
University of Michigan Engineering

resnick@cogsci.uiuc.edu (Pete Resnick) (06/29/91)

davids@mondo.engin.umich.edu (David Snearline) writes:

>Except that you would have to check the version of the system to see
>if _Gestalt exists...  :-)

No, no, no. Very bad. Check for the existence of the _Gestalt trap
by looking to see if it is in the trap table using NGetTrapAddress. You
*never* need to look at the version number of the operating system.

pr
--
Pete Resnick             (...so what is a mojo, and why would one be rising?)
Graduate assistant - Philosophy Department, Gregory Hall, UIUC
System manager - Cognitive Science Group, Beckman Institute, UIUC
Internet/ARPAnet/EDUnet  : resnick@cogsci.uiuc.edu
BITNET (if no other way) : FREE0285@UIUCVMD

lim@iris.ucdavis.edu (Lloyd Lim) (06/29/91)

In article <1991Jun29.040825.12123@ux1.cso.uiuc.edu> resnick@cogsci.uiuc.edu (Pete Resnick) writes:
>davids@mondo.engin.umich.edu (David Snearline) writes:
>
>>Except that you would have to check the version of the system to see
>>if _Gestalt exists...  :-)
>
>No, no, no. Very bad. Check for the existence of the _Gestalt trap
>by looking to see if it is in the trap table using NGetTrapAddress. You
>*never* need to look at the version number of the operating system.

Careful.  Never is a strong word.  You're correct about checking for Gestalt
(BTW, there's a new version of TrapAvailable in IM VI for those who don't
already know).

There are a few cases where you do have to check version numbers.  Here's
the ones I came up with after a quick scan through my code.

1)  If your app only runs on System 6.0.x and above, you obviously need to
check this.  If you assume System 6.0.x when programming, there's just too
much stuff to individually check.

2)  You can't call MultiFinder in versions 0x04FF and earlier with a sleep
value greater than 50.  This is documented.

3)  MultiFinder doesn't call SystemTask when the system is sleeping which
means you have to restrict your sleep values in System 6.0.x too.  This bug
is supposedly fixed in System 7.  (I haven't checked yet.)  I've mentioned
this before on the net but I haven't seen it in print.

4)  In System 6.0.3, the size of the left margin of menus changed.  This can
affect the appearance of popup menus.  This wasn't documented but was
acknowledged here on the net after people started complaining about it not
being documented.

I don't know any better ways to check for the above besides version numbers.
If anyone has any suggestions, I'll be glad to change my code.

+++
Lloyd Lim     Internet: lim@iris.eecs.ucdavis.edu
              America Online: LimUnltd
              Compuserve: 72647,660
              US Mail: 215 Lysle Leach Hall, U.C. Davis, Davis, CA 95616

time@ice.com (Tim Endres) (06/29/91)

In article <fck#ZlA@engin.umich.edu>, davids@mondo.engin.umich.edu (David Snearline) writes:
> Except that you would have to check the version of the system to see
> if _Gestalt exists...  :-)

NO. You use the standard Trap Available check for this.

-------------------------------------------------------------
Tim Endres                |  time@ice.com
ICE Engineering           |  uupsi!ice.com!time
8840 Main Street          |  Voice            FAX
Whitmore Lake MI. 48189   |  (313) 449 8288   (313) 449 9208
-------- USENET: A slow moving self parody.....

keith@Apple.COM (Keith Rollin) (07/01/91)

In article <fck#ZlA@engin.umich.edu> davids@mondo.engin.umich.edu (David Snearline) writes:
>In article <54449@apple.Apple.COM> nerm@Apple.COM (Dean Yu) writes:
>>In article <1991Jun27.125511.19565@runx.oz.au> mrd@runx.oz.au (Malcolm Davidson) writes:
>>>How do I test for the presence of system 7? I dont have access to
>>>IM VI as yet.
>>>
>>
>>  Oh boy, oh boy, I get to use a party line.  You should never assume the 
>>presence of a feature based on the version number of system software.  You 
>>should check for the presence of each feature specifically by using the _Gestalt
>>function.
>>
>
>Except that you would have to check the version of the system to see
>if _Gestalt exists...  :-)

No, you don't. Gestalt is _glue_, not a trap. There is a trap that
Gestalt uses internally, but you shouldn't call that directly.

-- 
------------------------------------------------------------------------------
Keith Rollin  ---  Apple Computer, Inc. 
INTERNET: keith@apple.com
    UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith
"But where the senses fail us, reason must step in."  - Galileo

keith@Apple.COM (Keith Rollin) (07/01/91)

In article <1991Jun29.040825.12123@ux1.cso.uiuc.edu> resnick@cogsci.uiuc.edu (Pete Resnick) writes:
>davids@mondo.engin.umich.edu (David Snearline) writes:
>
>>Except that you would have to check the version of the system to see
>>if _Gestalt exists...  :-)
>
>No, no, no. Very bad. Check for the existence of the _Gestalt trap
>by looking to see if it is in the trap table using NGetTrapAddress. You
>*never* need to look at the version number of the operating system.
>

No, no, no. Very bad. Check for the existance of Gestalt by looking
at the version number of your development system. Gestalt is _glue_;
it's in the libraries of the most recent development systems. You
don't have to check for a Gestalt trap. Just call it. If the trap
exists, the library routine will call it. If not, then the library
routine emulates it as well as it can.

-- 
------------------------------------------------------------------------------
Keith Rollin  ---  Apple Computer, Inc. 
INTERNET: keith@apple.com
    UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith
"But where the senses fail us, reason must step in."  - Galileo

keith@Apple.COM (Keith Rollin) (07/01/91)

In article <9235@ucdavis.ucdavis.edu> lim@iris.ucdavis.edu (Lloyd Lim) writes:
>In article <1991Jun29.040825.12123@ux1.cso.uiuc.edu> resnick@cogsci.uiuc.edu (Pete Resnick) writes:
>>davids@mondo.engin.umich.edu (David Snearline) writes:
>>
>>>Except that you would have to check the version of the system to see
>>>if _Gestalt exists...  :-)
>>
>>No, no, no. Very bad. Check for the existence of the _Gestalt trap
>>by looking to see if it is in the trap table using NGetTrapAddress. You
>>*never* need to look at the version number of the operating system.
>
>Careful.  Never is a strong word.  You're correct about checking for Gestalt
>(BTW, there's a new version of TrapAvailable in IM VI for those who don't
>already know).

I don't think that Pete is right with the part about checking for the
_Gestalt trap. Gestalt is a library routine. If you can successfully
link an application that calls Gestalt, then you are OK. The Gestalt
library routine in turn calls the _Gestalt trap, but it checks for the
existance of that trap itself; you don't have to.

-- 
------------------------------------------------------------------------------
Keith Rollin  ---  Apple Computer, Inc. 
INTERNET: keith@apple.com
    UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith
"But where the senses fail us, reason must step in."  - Galileo

keith@Apple.COM (Keith Rollin) (07/01/91)

In article <1CE00001.jevdup@tbomb.ice.com> time@ice.com writes:
>
>In article <fck#ZlA@engin.umich.edu>, davids@mondo.engin.umich.edu (David Snearline) writes:
>> Except that you would have to check the version of the system to see
>> if _Gestalt exists...  :-)
>
>NO. You use the standard Trap Available check for this.

No. Gestalt is glue. TrapAvailable() doesn't work on library routines.

-- 
------------------------------------------------------------------------------
Keith Rollin  ---  Apple Computer, Inc. 
INTERNET: keith@apple.com
    UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith
"But where the senses fail us, reason must step in."  - Galileo

resnick@cogsci.uiuc.edu (Pete Resnick) (07/01/91)

keith@Apple.COM (Keith Rollin) writes:

>In article <1991Jun29.040825.12123@ux1.cso.uiuc.edu> resnick@cogsci.uiuc.edu (Pete Resnick) writes:
>>davids@mondo.engin.umich.edu (David Snearline) writes:
>>
>>>Except that you would have to check the version of the system to see
>>>if _Gestalt exists...  :-)
>>
>>No, no, no. Very bad. Check for the existence of the _Gestalt trap
>>by looking to see if it is in the trap table using NGetTrapAddress. You
>>*never* need to look at the version number of the operating system.
>>

>No, no, no. Very bad. Check for the existance of Gestalt by looking
>at the version number of your development system. Gestalt is _glue_;
>it's in the libraries of the most recent development systems. You
>don't have to check for a Gestalt trap. Just call it. If the trap
>exists, the library routine will call it. If not, then the library
>routine emulates it as well as it can.

Well, according to Inside Mac VI, p. 3-32 to 3-33, the *proper* way to
do it is to look for the trap. Now, granted, some development
environments may implement Gestalt as glue, and people should use that
if they can (so their software is portable to operating systems before
6.0.4), but that means that your development environment is giving you
an extra piece of code to use. It does not mean that you should look at
the *operating system* version number, or even that you can depend on
the glue being available unless your development manufacturer documents
that they have such a thing. "Just call it" is *not* IMHO good advice.
I stand by my original statement:  The proper way to determine if
Gestalt is avaiable is to check to see if the trap is available and not
to look at the operating system version number.

pr
--
Pete Resnick             (...so what is a mojo, and why would one be rising?)
Graduate assistant - Philosophy Department, Gregory Hall, UIUC
System manager - Cognitive Science Group, Beckman Institute, UIUC
Internet/ARPAnet/EDUnet  : resnick@cogsci.uiuc.edu
BITNET (if no other way) : FREE0285@UIUCVMD