[comp.sys.mac] Calling "LAUNCH" from Pascal

rs4u#@ANDREW.CMU.EDU (Richard Siegel) (04/28/87)

This bit of code does it:

	PROCEDURE Transfer;
		TYPE
			pLaunchStruct = ^LaunchStruct;
			LaunchStruct = RECORD
					pfName : ^Str255;
					param : integer;
				END;  {LaunchStruct}

		VAR
			Reply : SFReply;
			ValidTypes : SFTypeList;
			volRef : Integer;
			Location : Point;
			prompt : Str255;
			pMyLaunch : pLaunchStruct;
			myLaunch : LaunchStruct;
			fName : Str255;
			err : OSErr;
	
		PROCEDURE LaunchIt (pLnch : pLaunchStruct);
		INLINE
			$205F, $A9F2;

	BEGIN
		SetPt(Location, 90, 90);
		validTypes[0] := 'APPL';
		SFGetFile(Location, prompt, NIL, 1, validTypes, NIL, Reply);

		IF Reply.good THEN
			BEGIN
				pMyLaunch := @myLaunch;
				WITH pMyLaunch^ DO
					BEGIN
						pfName := @Reply.fName;    {pointer to our fileName}
						param := 0;          {we don't want alternate screen or sound buffers}
					END;	 {With}
				err := SetVol(NIL, reply.vRefNum);
				LaunchIt(pMyLaunch);
			END;
	END;


This is the same technique used in Macintosh Technical Note #52.

		--Rich


Richard M. Siegel
Materials Characterization Instrumentation Section
Mail Stop 231
NASA/Langley Research Center
Hampton, Virginia 23665
(804) 865-3036

Arpanet: rs4u@andrew.cmu.edu
Uucp: {your fave gateway}!seismo!andrew.cmu.edu!rs4u

Disclaimer? I don't even KNOW 'er!

naresh%orstcs2@oregon-state.CSNET.UUCP (04/29/87)

Thanks a lot for response, I will implement it and hope it works for me.
Thanks again.
Naresh Gupta
Oregon State U.
Corvallis

huxham@apple.UUCP (Fred Huxham) (04/30/87)

Before people go off and spend a lot of time implementing
_Launch in all their software, let me give you the 
following warning:

(The following is from a TechNote to be released the first
week of May or so)

"The interface to the Launch trap will change in the not-too-
distant future.  When that happens, programs which launch
other applications will break.  You should really only consider
doing this if you are implementing an integrated development
system"

The technote goes on to describe sublaunching, a new feature
of System 4.1.  This is the mechanism people should use
to launch applications from within their own.

I would advise people to wait the week or two for the
technote before implementing a lot of Launch code that
will have to be changed.

Fred