Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!unmvax!tut.cis.ohio-state.edu!att!pegasus!ech From: ech@pegasus.ATT.COM (Edward C Horvath) Newsgroups: comp.sys.mac.programmer Subject: Re: help with sublaunching Message-ID: <2856@pegasus.ATT.COM> Date: 3 May 89 20:18:56 GMT References: <9410@j.cc.purdue.edu> Distribution: usa Organization: AT&T ISL Middletown NJ USA Lines: 46 From article <9410@j.cc.purdue.edu>, by aib@j.cc.purdue.edu (coleman): > HELP !! > I am having major problems with sublaunching... > pascal OSErr LaunchIt( pLnch) /* < 0 means error */ > pLaunchStruct pLnch ; > { > asm { > MOVE.L (A7)+,A0 > _Launch > MOVE.W D0,(A7) ; since it MAY return */ > } > } Depending on how your C compiler works -- I assume this is LSC from the asm{...} -- you have either one or two longwords on the stack on top of the address of the launch parameters, namely the return address, and perhaps the old value of A6. There is also no need for the pascal keyword, since d0 is where _Launch leaves its result code, and where a C caller expects to find it. LSC also lets you access parameters symbolically. Thus, the following: OSErr LaunchIt (pLnch) pLaunchStruct (pLnch); { asm { move.l pLnch,a0 _Launch } } That's it. In fact, if you have the LaunchStruct, you can embed the trap right in your other routine: LaunchStruct Lnch; OSErr rslt; ... /* set up Lnch */ asm { lea Lnch,a0 _Launch move.w d0,rslt } =Ned Horvath=