Newsgroups: comp.os.msdos.programmer
Path: utzoo!telly!druid!darcy
From: darcy@druid.uucp (D'Arcy J.M. Cain)
Subject: Re: Command.com and a message
Organization: D'Arcy Cain Consulting, West Hill, Ontario
Date: Thu, 6 Dec 90 13:08:31 GMT
Message-ID: <1990Dec6.130831.21715@druid.uucp>
References: <67560@unix.cis.pitt.edu>

In article <67560@unix.cis.pitt.edu> Karol Gieszczykiewicz writes:
>	Greetings. I am a C programmer with a bit of 8088 assembly
>	"fooling around". I am writing a program that has to load
>	command.com (shell). It works, but I want it to display
>	a little message that reminds the user of what they did.
>	(just so they don't run my program again, instead of "exit"-
>	ing back to it).
>
>	I know it's possible because WordPerfect does it. Every time
>	one presses <enter>, after exiting to shell, a short message
>	appears, telling the user to type "exit" to return to

I don't believe you can make command.com do that but it would be simple
to change the prompt.  Try this:

reminder    db    'PROMPT=Type EXIT to return to FOOBAR', 0dh, 0ah
old_prompt  db    MAX_PROMPT dup ?

Now find the environment string for "PROMPT" and copy it to old_prompt.
Create a new environment space (leave some room for child processes) and
replace the PROMPT string with the above.  Now when you EXEC just point
to this new environment and VIOLA! instant annoying reminder.

See the DOS Technical Reference Ch. 7 (DOS Control Blocks and Work Areas)
for more information on the DOS Program Segment and the environment.

One more point.  If it is a problem to run your program twice, you should
probably try to prevent this.  A simple (but not perfect) solution is to
create a lockfile somewhere when you run and check for it on startup.  If
it already exists then abort.  If not then create it.  Don't forget to
erase it when finished running the program.  In fact this may be a better
solution than modifying the prompt.  If the file exists simply explain
that the program is already running and describe how to return to it at
that point.  E.g:

C> foobar
**NOTE** FOOBAR is already running.
To return to it enter the command 'EXIT'
C>

If you use the lock file scheme it would be a good idea to add an erase
command to your autoexec.bat for those power failures, tripped over plugs
and three fingered salutes.

-- 
D'Arcy J.M. Cain (darcy@druid)     |
D'Arcy Cain Consulting             |   There's no government
West Hill, Ontario, Canada         |   like no government!
+1 416 281 6094                    |
