Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!hp4nl!ruuinf!accucx!pluto.phil.ruu.nl!jeroen From: jeroen@pluto.phil.ruu.nl (Jeroen Scheerder) Newsgroups: comp.sys.atari.st.tech Subject: How am I called? Why O Why... Message-ID: <1147@accucx.cc.ruu.nl> Date: 5 Feb 91 13:43:07 GMT Sender: news@accucx.cc.ruu.nl Reply-To: jeroen@pluto.phil.ruu.nl (Jeroen Scheerder) Organization: Logic section, Department of Philosophy, Utrecht Lines: 46 Hi, I have trouble with a routine posted on the net about a year ago. The routine *should* distinguish between calls of a program from the desktop, calls from another shell and from the auto folder. Here's the routine (_BasPag is a global var pointing to the basepage of the program): #define FROM_AUTO 1 #define FROM_DESKTOP 2 #define FROM_SHELL 3 #include int HowStarted(void) { BASPAG *p = _BasPag; register int n = 0; p = p->p_parent; if((((long) (p->p_tbase)) & 0x800000L) == 0L) return(FROM_SHELL); while((p = p->p_parent) != 0L) ++n; return((n == 1) ? FROM_AUTO : ((n == 2) ? FROM_DESKTOP : FROM_SHELL)); } void main(void) { switch(HowStarted()) { case FROM_AUTO: Cconws("Auto!"); break; case FROM_DESKTOP: Cconws("Desktop!"); break; case FROM_SHELL: Cconws("Shell!"); } } The problem is: from the auto folder it writes "Auto!", from a shell it writes "Shell!" and from the desktop it writes... "Shell!". Does anyone spot the bug in the source? Please mail me. Thanx in advance, J.