Dec 282017
 
Push & Pop Paths.
File PUSHPATH.ZIP from The Programmer’s Corner in
Category Utilities for DOS and Windows Machines
Push & Pop Paths.
File Name File Size Zip Size Zip Type
ADDPATH.BAT 984 478 deflated
POPPATH.BAT 1548 632 deflated
PUSHPATH.BAT 1420 621 deflated
PUSHPATH.DOC 5930 2369 deflated

Download File PUSHPATH.ZIP Here

Contents of the PUSHPATH.DOC file




PushPath
or, Leading the user down the Path Garden
Craig Goodrich
Pussycat Systems
17632 Towne Crest Dr
Gaithersburg, MD 20877
phone (voice) 301 869-2297

The DOS 2.0+ tree-structured directory feature is indispensable for
keeping track of applications on a hard disk, but can drive the user
crazy typing directory specs in front of every command --
\DOS\BIN\UTIL\SORT, etc. -- so of course we have the complementary PATH
facility, which tells COMMAND.COM where to look for programs not in the
currently logged directory.

But there is a problem with this -- many, if not most, application
programs require auxiliary data and configuration files, and they don't
bother to search the specified path to find them. They generally expect
to find these files in the currently logged directory. Moreover, for
those applications which do search the path for their own files, this
search can be quite lengthy, especially on a large disk.

Furthermore, the programmer or other power user is frequently
moving from directory to directory, sometimes quite deep in the
tree, and may be running an obscure little program which lives
in a distant cousin directory of wherever he may be at the moment.

These considerations suggest that it would be useful if DOS
could provide some method of saving and restoring the PATH setting,
similar to, for example, Data General's AOS "Push" and "Pop" commands
(which actually save and restore the entire job environment).

One widely used method of organizing work is to set up
a batch file for each application in some "home" directory
(e.g. C:\ ), with typical files looking something like this:

(WS.BAT)
echo off
c:
cd \
rem . . just in case we were somewhere else . . .
rem Save current path in batch file
path > poppth
subst h: c:\ws\memos { note: DOS 3.1 only }
rem Shorten path to save dos search time
path c:\dos
rem go to the application
cd \ws
rem Poor dumb ws doesn't understand directories
ws h:%1
rem Clean up
subst h:/d { note: DOS 3.1 only }
rem Back up the tree
cd \
rem Restore old path
poppth

While this is convenient in batch files, it is cumbersome
for interactive flitting from leaf to leaf. The batch files in
this archive are designed for interactive path pushing and popping
(since regrettably one of the simple-minded aspects of DOS' batch
facility is that batch files can't be nested, they can't be used
in batch files, although they could be copied as prefix and suffix
to any existing batch file).

The three batch files included are:

PushPath -- saves current path in environment string area.
Optionally sets new path specified on command line.
PopPath -- retrieves and sets last path PUSHed.
(Note: The stack depth for these procedures is 5;
this could be increased -- an exercise for the reader --
but beware of slower running and exhausting environment
string space [see additional notes below]).
AddPath -- tacks another directory spec onto the current path.
If /f is specified, it puts it at the head of the path
string, otherwise at the end.

The files are more or less self-explanatory, but the following
points may be helpful to the technically-inclined novice:

1. If the typical path string is long and involved, DOS'
default 128-byte environment space will be exhausted
quickly. To enlarge the space, include the following
line in your CONFIG.SYS file (DOS 3.x only):
shell=\command.com /p /e:nnnn
where nnnn is the number of 16-byte paragraphs to reserve
for environment space. 0040, 64 paragraphs or 1k bytes,
should be enough for any reasonable application. Lord
knows DOS hogs enough of your precious 640 already.
The /p is important; it means "permanently resident"
and if it's not there, AutoExec won't be run.

2. In batch files, %BUNNY% means the current setting of
the environment variable BUNNY, which got there by
a SET BUNNY=whatever command.

3. For DOS 2.x, if environment space is a problem, you
may wish to store the pathstrings in batch files in
the home directory, using the stack-handling logic
of the respective batch files. You would replace
the PushPath line
set oldpath%pstack%=%path%
with
path >\pth%pstack%.bat
, for example, and modify PopPath to invoke
the appropriate file. This is again (he weaseled)
Left As An Excercise For The Reader.

4. It is possible to completely confuse Push and Pop by
interactively resetting the variables they use, i.e.
PSTACK and the OLDPATH family. If you (perversely)
do this, you may wish to create a batch file such
as
(CLRPSTAK.BAT)
for %%s in ( pppp ppp pp p ) do set oldpath%%s=
set pstack=
and start over.

Happy Batching!


 December 28, 2017  Add comments

Leave a Reply