[net.micro.pc] batchfile helper

nather@utastro.UUCP (Ed Nather) (06/26/86)

I was unable to send this mail message successfully, but it has content
which might be of general interest, so I am posting it in hopes the
target will see it ...
------------------------------------------------------------------------

To: gorgo!ddrex
Subject: re: echo off (& errorlevels)

I'm glad you got the "echo off" patch to work.  I had hoped different
clones would be able to "do the right thing."

The errorlevel problem:  I don't know how exit(1) works on CI-C86, but I
have had no trouble returning an errorlevel so long as DOS function 4C is
the exiting call.  If CI-C86 doesn't generate that exit, then that could
be the problem.

As an example of its use, here's a huge (9 byte) program that returns, as
an errorlevel value, the number of the current default drive.  I use it 
in conjunction with the DOS 3.1 "subst" command when I run programs that
were written for a two-floppy system and don't understand pathnames.  You
can get the current drive value, then "subst" a phony drive for the
pathname of the directory with the old program in it, and then "go there"
in a .bat file.  You can now refer to files in your original directory
by preceding the filename with the drive designator. Afterwards you can 
return to your original directory by using the drive as a command.

Here's the "debug script" to generate the program, which I call "mkdrv.dbs."
Put it in a file with that name and type

     dubug drv.com < mkdrv.dbs

to get the executable.  Below the "debug script" is a .bat file that uses it.
---------------------------------------------------------------------------
a
---------------------------------------------------------------------------
:run desmet compiler from its directory
drv
if errorlevel 0 set DRV=a:
if errorlevel 1 set DRV=b:
if errorlevel 2 set DRV=c:
subst e: c:\desmet
e:
c88 %DRV%%1 
if errorlevel 1 goto stop
echo 
bind %DRV%%1 
:stop
%DRV%
subst e: -D

-- 
Ed Nather
Astronomy Dept, U of Texas @ Austin
{allegra,ihnp4}!{noao,ut-sally}!utastro!nather
nather@astro.AS.UTEXAS.EDU