Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!uc!nic.MR.NET!nic.stolaf.edu!chopin.psu.edu From: hannum@chopin.psu.edu (Charles Hannum) Newsgroups: comp.sys.next Subject: Re: Can an App launch itself? Message-ID: <614@nic.stolaf.edu> Date: 9 Jun 90 01:09:57 GMT Sender: news@nic.stolaf.edu Distribution: comp Organization: The Pennsylvania State University Public NeXT Laboratory Lines: 57 Yes, this is really quite simple. If you're using the Interface Builder, then all you need to do is this: (Note that this is all from memory, so don't flame me if it's not quite right. It should give you enough info to figure it out on your own.) #import extern char *appname; [[NXApp appSpeaker] setSendPort:NXPortFromName(NX_WORKSPACEREQUEST, NULL)]; [[NXApp appSpeaker] openFile:appname]; In your main program, do this: char *appname; /* Blah, blah */ int main(int argc, char **argv) { appname = *argv; /* Blah, blah */ } That should do exactly what you want, shart a fresh copy of the application. Hm. Maybe someone at NeXT could put a 'Spawn' button in Terminal ... B-) Now, if you're *not* using the Interface Builder, you can do this: #import id mySpeaker; /* Blah, blah */ mySpeaker = [Speaker New]; [mySpeaker setSendPort:NXPortFromName(NX_WORKSPACEREQUEST, NULL)]; [mySpeaker openFile:appname]; [mySpeaker free]; NOTE: You could keep the Speaker allocated throughout the program; you really don't need to deallocate it. It's just a matter of your personal preference. (I'd say 'Hope this helps.', but I know it will ... B-) ObQuery: Is there a global version of 'argv'? Then I wouldn't have to have main() store a pointer to the app's name; I could just reference argv[0] every time. -- Virtually, Charles Martin Hannum "Those who say a thing cannot be done should Please send mail to: under no circumstances stand in the way of hannum@schubert.psu.edu he who is doing it." - a misquote