bwb@andante.UUCP (Bruce Ballard) (08/08/89)
How can I achieve a Launch in Lightspeed C? I've studied TN-126 on (Sub)Launching, and I've read the pages 3-17/3-18 in Programmer's Guide to MultiFinder, but I always get a beep followed by a termination of my program, which according to p. 3-18 means an error has occurred when I'm not asking to sublaunch. But I've (tried to) set LaunchFlags to 0xC0000000. Any hints? I'm running with LSC 3.0 under MultiFinder on a Mac II with lots of megs. Here's how I define the interface: typedef struct LaunchStruct { char *pfName; short int param; char LC[2]; long int extBlockLen; short int fFlags; long int launchFlags; } LaunchStruct; pascal OSErr LaunchIt(pl) LaunchStruct *pl; { asm { move.l (a7)+,a0 _Launch move.w d0,(a7) } } and here's the code: LaunchStruct myLaunch; HFileInfo myPB; SFReply reply; SFTypeList typs = {'APPL', 0, 0, 0}; Point sfpoint = {10,10}; MyLaunch(sublaunch) int sublaunch; {OSErr err; SFGetFile(sfpoint, "", 0L, 1, typs, 0L, &reply); if (!reply.good) return; myPB.ioNamePtr = (StringPtr)reply.fName; myPB.ioVRefNum = reply.vRefNum; myPB.ioFDirIndex = 0; myPB.ioDirID = 0; err = PBGetCatInfo((CInfoPBPtr)&myPB, false); if (err != noErr) return; err = SetVol(0L, reply.vRefNum); if (err != noErr) return; myLaunch.pfName = (char *)&reply.fName; myLaunch.param = 0; myLaunch.LC[0] = 'L'; myLaunch.LC[1] = 'C'; myLaunch.extBlockLen = 6; myLaunch.fFlags = myPB.ioFlFndrInfo.fdFlags; if (sublaunch) myLaunch.launchFlags = 0xC0000000; else myLaunch.launchFlags = 0x00000000; LaunchIt(&myLaunch); }
zben@umd5.umd.edu (Ben Cranston) (08/09/89)
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 <zben@umd2.UMD.EDU> * Computer Science Center Network Infrastructures Group * University of Maryland at College Park