Path: utzoo!utgpu!watmath!att!tut.cis.ohio-state.edu!mailrus!ncar!ames!haven!umd5!zben From: zben@umd5.umd.edu (Ben Cranston) Newsgroups: comp.sys.mac.programmer Subject: Re: Launching from LSC Summary: Gee, it looks good to me Message-ID: <5180@umd5.umd.edu> Date: 8 Aug 89 19:59:50 GMT References: <21866@andante.UUCP> Reply-To: zben@umd5.umd.edu (Ben Cranston) Organization: University of Maryland, College Park Lines: 105 In article <21866@andante.UUCP> bwb@andante.UUCP (Bruce Ballard) writes: > How can I achieve a Launch in Lightspeed C? > I always get a beep followed by a termination of my program > (source code posted) Gee, guy, your code looks perfectly good to me, and it's almost identical to what I am using with MPW 3.0 C (code below). I would take a hard flinty look at that assembly code procedure to see if LSC is mucking about with the stack frame before your assembly gets control. My code is almost identical to yours, and it even cheats by not reading the file information flags :-( typedef struct { char *ApName; /* Pointer to application name */ short int BufCon; /* Config sound/screen bufs */ char XFlag[2]; /* Extended launch flag */ long int XLen; /* Extended info length */ short FFlags; /* Finder info flags */ long int LFlags; /* Launch option flags */ } LaunchPacket, *LaunchPtr; ... /* Do launch of another application. * Note negative result is error, but positive is "process id" ... */ pascal OSErr LaunchCall( LaunchPtr ) = { 0x205F, /* Move.L (SP)+,A0 ; Arg to A0 */ 0xA9F2, /* _Launch ; Launch app */ 0x3E80 /* Move.W D0,(SP) ; Return result */ }; LaunchApp(appname) char *appname; { char filen[256]; short int refnum; LaunchPacket mylaunch; OSErr errcode; if (0 != (errcode=GetWD(appname,&refnum,filen)) ) return(errcode); if (0 != (errcode=SetVol(nil,refnum)) ) return(errcode); mylaunch.ApName = filen; mylaunch.BufCon = 0; mylaunch.XFlag[0] = 'L'; mylaunch.XFlag[1] = 'C'; mylaunch.XLen = 6; mylaunch.FFlags = 0; mylaunch.LFlags = 0xC0000000; if ( 0 > (errcode=LaunchCall(&mylaunch)) ) { return(errcode); } return(0); } .... /* Split the path string into directory and filename. * Open a working directory on the directory portion. * Return the working directory and filename portion to caller. */ OSErr GetWD(path,refn,fname) char *path; short *refn; char *fname; { int len, idx; short dvol; char dname[255]; OSErr errcode; WDPBRec WDPB; for ( len=idx=path[0] ; (idx>1) && (path[idx]!=':') ; idx-- ) ; dname[0] = idx-1; memcpy(&dname[1],&path[1],idx-1); fname[0] = len-idx; memcpy(&fname[1],&path[idx+1],len-idx); if ( 0 != (errcode=GetVol(nil,&dvol)) ) return(errcode); WDPB.ioNamePtr = dname; WDPB.ioVRefNum = dvol; WDPB.ioWDProcID = 'XIDL'; WDPB.ioWDDirID = 0; if ( 0 != (errcode=PBOpenWD(&WDPB,false)) ) return(errcode); (*refn) = WDPB.ioVRefNum; return(0); } -- Sig DS.L ('ZBen') ; Ben Cranston* Computer Science Center Network Infrastructures Group * University of Maryland at College Park