larryh@tekcbi.UUCP (Larry Hutchinson) (02/24/86)
The following C fragment (module actually) is meant to be called from a Quit To ... menu item. It allows another program to be started up with out going to the Finder (like SkipFinder, but built in). I am posting it for two reasons: (1) I like programs that provide this feature and (2) I would like to know if it is correct. I know it works but don't know if it is the "proper" way of doing it. Responses should go to me or to net.micro.mac. The program is written in Aztec C and will need some modification for other dialects. [note: the \P generates a Pascal string and the keyword "Pascal" generates a routine that can be called from Pascal] Larry Hutchinson, Tektronix, Inc. PO Box 500, MS 02-305, Beaverton, OR 97077 { decvax,allegra }!tektronix!tekcbi!larryh -----------------cut here-------------------- /* launch.c * * defines launch() * allows user to start another program directly */ #include <pb.h> #include <packages.h> #include <segment.h> #include <dialog.h> #include <control.h> struct launchinfo { char *name; short code; }; static struct launchinfo lprog; pascal int makerun(itemNo,theDialog) /* makes open button say run */ int itemNo; /* this came from MacUser magazine */ DialogPtr theDialog; { int type; Handle item; Rect box; if(itemNo == -1){ GetDItem(theDialog,1,&type,&item,&box); SetCTitle((ControlHandle) item, "\PRun"); } return itemNo; } launch() /* run another program */ { SFReply repl; SFTypeList appltypes; appltypes[0]= 'APPL'; SFGetFile(100,100,0L,0L,1,appltypes,makerun,&repl); if(!repl.good) return(); lprog.name= repl.fName; lprog.code= 0; SetVol(0L,repl.vRefNum); /* this should work with HFS,no? */ #asm lea lprog_,a0 dc.w $a9f2 #endasm ExitToShell(); /* should never hapen */ }