Path: utzoo!utgpu!watserv1!ria!uwovax.uwo.ca!7103_2622 From: 7103_2622@uwovax.uwo.ca (Eric Smith) Newsgroups: comp.sys.atari.st.tech Subject: Re: Can my program find its name? Message-ID: <1991Feb18.205200.8638@uwovax.uwo.ca> Date: 19 Feb 91 01:52:00 GMT References: <2133022@nuthaus.UUCP> Lines: 21 In article <2133022@nuthaus.UUCP>, nut@nuthaus.UUCP (Adam G. Tilghman) writes: > > I am writing a program which needs to find out its own name - > I know this is possible, but how is it done? The only way that > I can think of is back-tracing into the parent program to find the > Pexec() parameters, but this doesn't ring very kosher to me :-) > Is there a better way? > Indeed, this is a very bad thing to do -- certainly it will fail big time under MiNT, and probably under RTX and other systems (including, perhaps, future versions of TOS). There is an AES call that can get the program name if the program was started from the desktop. If you were started from a shell that supports the mwc/Atari extended argument passing conventions, the program name is put in the environment after the variable ARGV=. Some C compilers will automatically put this into argv[0] (gcc and mwc will). -- Eric R. Smith email: Dept. of Mathematics eric.smith@uwo.ca University of Western Ontario 7103_2622@uwovax.bitnet