[comp.sys.handhelds] PUSHD and POPD

jthornto@fs1.ee.ubc.ca (THORNTON JOHAN A) (11/19/90)

Here are PUSHD and POPD, two utilities that I find often come in handy.  PUSHD
of course saves your current directory in a directory stack, and POPD pulls
off the last place where you were.  The directory paths are stored as lists
in a list called DPATH, which you must create in the root directory.
( HOME {} 'DPATH' STO )

I hope you are using the HOME-MAIN utility management method; put the programs
in the HOME directory.  If you're stingy with memory, kill the error message
from POPD - remove everything between DROP and END.


@ PUSHD - push current directory
%%HP: T(3)A(D)F(.);
\<< PATH DUP 1 \->LIST
HOME 'DPATH' STO+
EVAL
\>>


@ POPD - pop directory
%%HP: T(3)A(D)F(.);
\<< HOME DPATH OBJ\-> DUP
  IF
  THEN 1 - \->LIST
'DPATH' STO EVAL
  ELSE DROP
"POPD Error:" 1
"Directory Stack Empty"
2 DISP DISP 1
FREEZE
  END
\>>

 -------  _/__/   -----------------------------------------------------
        _|  ___|    E l e c t r i c a l      |  Johan Thornton, Esq.
       | | |_/     E n g i n E E r i n g     |-------------------------
       |/|  __|     U n i v e r s i t y      |  jthornto@fs1.ee.ubc.ca
       |-| |/__     o f   B r i t i s h      |-------------------------
       | |_____|      C o l u m b i a        |   This space for rent
 ----  |__|/_|   ------------------------------------------------------

akcs.matty@hpcvbbs.UUCP (_/. Matthew Huyck) (01/29/91)

I have another program to do the same thing as the above one, but uses
less memory because it's shorter.  It also doesn't require a variable
in my otherwise stuffed HOME directory.
I'll just type it in 'cause it's so short...

<<  PATH -> p  << HALT p EVAL 2 MENU >>  >>

To go back to your old directory, just CONT (orange-shift ON).
I hope this is of use to someone.