[comp.sys.mac.programmer] determining if MF is running...

sonenbli@oxy.edu (Andrew D. Sonenblick) (12/01/89)

ok, I'll probably be flamed, but when I distribute my beta versions to
people to test it and when it's a version that as yet does not work
properly/at all under MultiFinder, I simply check to see whether the
next to last item in the apple menu is a dotted line... (after all, I don't
know of any program in the past 6 years that ever had a line there except
MF) and if so I kindly alert the user that their mac will self destruct,
just kidding, I tell them that I'm MF unfriendly and then close myself...

mm3d+@andrew.cmu.edu (Matt McNally) (12/01/89)

For those of you who don't have access to the "Programmers Guide
To MultiFinder" here are some MPW Pascal Code segments that will
check for the existance of MF functionality and a few simple 
functions that use them.  These were basically extracted from some
examples found in the aforementioned 'Guide'.

Hope they help.

-Matt

------


Function TrapAvailable(trapNum:Integer; tType: TrapType):Boolean;
{ *** TrapAvailable ***: This routine verifies the existance of a 'trap'. }

Const
	BadTrap = $A89F;
	
Begin
	TrapAvailable := (NGetTrapAddress(trapNum,tType) <>
						GetTrapAddress(BadTrap));
End;   { ~ of Function TrapAvailable }


Function MFMemIsAvail:Boolean;
{ *** MFMemIsAvail ***: This function returns true if MF Memory Calls are
						available. Note: No need to check for seperate trap
						tables since memory calls are OS Traps. }

Const
	MemTrap = $A88F;
	
Begin
	MFMemIsAvail:= TrapAvailable(MemTrap,ToolTrap);
End;   { ~ of Function MFMemIsAvail }


Function WNEIsAvail:Boolean;
{ *** WNEIsAvail ***: Returns true if WaitNextEvent() is available.}

Const
	WNEvtTrap = $A860;

Var
	tmpErr:	OSErr;
	tmpEnv: SysEnvRec;
	
Begin
	tmpErr:=SysEnvirons(1,tmpEnv);
	
	if tmpEnv.machineType<0 Then
		WNEIsAvail:=False
	  Else
	    WNEIsAvail:=TrapAvailable(WNEvtTrap, ToolTrap);

End;   { ~ of Function WNEIsAvail}


Function MacMemTotal:Integer;
{ *** MacMemTotal ***: Returns the total memory (in K ) available on the 
					   machine, NOT the total available to the application.}
					
Begin
	If MFMemIsAvail then
		MacMemTotal:=(Ord4(MFTopMem) div 1024)
	Else
		MacMemTotal:=(Ord4(TopMem) div 1024);
End;   { ~ of Function MacMemTotal}



=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Matt M. McNally - 'Macintosh II Project' Research Programmer/Dugan
                    Carnegie Mellon, H&SS Dean's Office, Pittsburgh, PA 15213
                    Office: Baker Hall 369-B, (412) 268-6990

                    ARPANET Address: mm3d@andrew.cmu.edu
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 

keith@Apple.COM (Keith Rollin) (12/02/89)

In article <64583@tiger.oxy.edu> sonenbli@oxy.edu (Andrew D. Sonenblick) writes:
>ok, I'll probably be flamed, but when I distribute my beta versions to
>people to test it and when it's a version that as yet does not work
>properly/at all under MultiFinder, I simply check to see whether the
>next to last item in the apple menu is a dotted line... (after all, I don't
>know of any program in the past 6 years that ever had a line there except
>MF) and if so I kindly alert the user that their mac will self destruct,
>just kidding, I tell them that I'm MF unfriendly and then close myself...

What if this dotted line isn't there in the future? What if the "About Multi-
Finder" stuff is incorporated into the normal "About Finder" menu item, or
removed altogether? (Consider the chances of this rather high.)

Answer: you die...

-- 
------------------------------------------------------------------------------
Keith Rollin  ---  Apple Computer, Inc.  ---  Developer Technical Support
INTERNET: keith@apple.com
    UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith
"Argue for your Apple, and sure enough, it's yours" - Keith Rollin, Contusions