jeroen@pluto.phil.ruu.nl (Jeroen Scheerder) (02/05/91)
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 <tos.h>
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.