[comp.sys.amiga] Did they RUN me?

billk@crash.UUCP (02/17/87)

Yet another question: (Many thanks to those who were able to help me with the
previous ones...!)

How can I find out whether a user has RUN my program or has just executed it?

Now, I really don't want just a 'C' call as an example.  I am more after what
that call(s) is really doing.   I need to know what structure(s) this call(s)
looks into and how it gets the pointer(s) to these structure(s)...

Thank(s) ;-)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NAME: Bill Kelly
UUCP: {akgua, hplabs!hp-sdd, sdcsvax}!crash!pnet01!billk
ARPA: crash!pnet01!billk@nosc
INET: billk@pnet01.CTS.COM
USPS: 2507 Caminito La Paz
      La Jolla, CA  92037       "There's never time to do it right,
FONE: (619) 454-1307             but always time to do it over..."

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

billk@crash.UUCP (02/20/87)

Sorry about my last message on this subject -- confusing things were happening
all around me while I was writing it and I had to leave suddenly.  Other than
the fact that it probably made no sense, it was a great message... ;-)

Here's what I was trying to ask:

Take a look at the following two examples of someone executing a program
from the CLI:

Example 1:
1> DiskEd
... ... ... ...
Example 2:
1> RUN DiskEd
[CLI 2]
1>
... ... ... ...

Now, Is there any nice way for "DiskEd" to determine whether the user has RUN
it (example 2) or they have just executed it (example 1)?
What I'm really interested in is EXACTLY what "DiskEd" must do to obtain this
information.  Since I'm not programming in 'C' it would help me more to have
an example like, "Oh, you just have to look in structure So_and_so which is at
the beginning of all CLI tasks and get the pointer to StdIn...etc." rather
than an example like, "Hey, no problem -- just call good 'ol DreelSprail() to
get the job done! ...'works every time..." because I would have no idea at all
as to what "DreelSprail()" might be doing...  Thanks!

While I'm at it, I might as well ask how, once "DiskEd" has found out whether
it has been RUN or not... How can "DiskEd" find out the following?:

Suppose it hasn't been RUN.  Then how can DiskEd find the pointer (what is it,
a DOS file lock?) to the CLI window it has been RUN from, so it can do text
into it?  Remember, I'm not programming in 'C' :)  Thanks!

I will be most grateful if someone can help.  I don't like having this all so
one-way, though.  I wish I could help a little instead of always asking
questions -- SO, if anyone has any questions about the Amiga Devices, Fire
Away!  I'd be quite surprised if I couldn't help with *those*, having written
complete interfaces to almost all of them.  (They get easier the more you do,
for the most part)

Thanks again!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NAME: Bill Kelly
UUCP: {akgua, hplabs!hp-sdd, sdcsvax}!crash!pnet01!billk
ARPA: crash!pnet01!billk@nosc
INET: billk@pnet01.CTS.COM
USPS: 2507 Caminito La Paz              "I hate operating systems!"
      La Jolla, CA  92037                      Guy M. Kelly
FONE: (619) 454-1307

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

carolyn@cbmvax.UUCP (02/21/87)

In article <808@crash.CTS.COM> billk@pnet01.CTS.COM (Bill Kelly) writes:

>How can I find out whether a user has RUN my program or has just executed it?

By "executed" I assume you mean that the user just typed your program
name at the CLI prompt.

Here's the general idea (#include <libraries/dos.h>, <libraries/dosextens.h>)
Note that this example is only valid for programs started from CLI since
programs started from Workbench do not have CommandLineInterface structures.

...
TheyRanMe = FALSE;
proc = (struct Process *)FindTask(NULL);

if(proc->pr_CLI)  /* if started from CLI */
   {
   cli = (struct CommandLineInterface *)((proc->pr_CLI)<<2);
   if(cli->cli_Background)  TheyRanMe = TRUE;
   }
...

 
-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Carolyn Scheppner -- CBM   >>Amiga Technical Support<<
                     UUCP  ...{allegra,caip,ihnp4,seismo}!cbmvax!carolyn 
                     PHONE 215-431-9180
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=