Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!usc!apple!portal!cup.portal.com!Bobster From: Bobster@cup.portal.com (Robert Jules Shaughnessy) Newsgroups: comp.sys.atari.st.tech Subject: Re: Can my program find its name? Message-ID: <39432@cup.portal.com> Date: 20 Feb 91 00:55:57 GMT References: <2133022@nuthaus.UUCP> Organization: The Portal System (TM) Lines: 29 Just a thought, but you might be interested in my train of thought. A file is executed by the following: pea env Enviroment pea com Comand Line Address pea fil file name address (What you want) move.w #0,-(sp) Load and Start (Execute the file) move.w #$4b,-(sp) Function number trap #1 (Call gemdos) add.l #16,sp correct the stack With this in mind, all you should have to do is the followin sub #4,sp (Subtract 4 from the stack pointer and you should be pointing at the address of the file name. (This could be -8 instead of 4)) movea (sp)+,a0 (Move the file name address into a0) Now all you need to do is start reading at that address until you hit a 0 (End of file name marker) and you will have the file name the original program used. (I think this will work in all situations. Be sure to not mess with the stack before you do this though. It will probably need to be the first thing you do. Oh and dont forget to correct the stack when you done.) I am not 100% I have this correct, but I am sure someone will tell me if I am at error... ;^) I hope this helps a little.