POPD Procedure
Standard Library procedure that pops a directory from the top of a last-in, first-out directory stack.
Usage
POPD
Parameters
None.
Keywords
None.
Discussion
POPD changes the current working directory to the directory saved on the top of the directory stack. The stack is maintained by the PUSHD and POPD procedures. This top directory is then removed from the stack. (If you try to pop from an empty stack, an error message is displayed.)
Directories that have been pushed onto the stack are removed by the POPD procedure. The last directory pushed onto the stack is the first directory popped out of it. There is no limit to how deep directories may be stacked.
Example
In this example, PUSHD is used to change the current working directory. The current working directory is pushed onto the directory stack before moving to the subdirectory. Procedure POPD is used to change the current working directory to the directory at the top of the directory stack. Thus, you are returned to the original working directory. Procedure PRINTD is used to view the current working directory and the directory stack before and after the execution of PUSHD and POPD.
UNIX Examples
In this example, PUSHD is used to change the current working directory. The current working directory is pushed onto the directory stack before moving to the subdirectory. Procedure POPD is used to change the current working directory to the directory at the top of the directory stack. Thus, you are returned to the original working directory. Procedure PRINTD is used to view the current working directory and the directory stack before and after the execution of PUSHD and POPD.
CD, !Dir
; Display the current working directory and the directory stack.
PRINTD
; Push current working directory onto the directory stack, and
; move to the subdirectory /lib/user.
PUSHD, 'lib/user'
; Display the current working directory and the directory stack. 
; Note that top of stack contains the previous working
; directory.
PRINTD
; Move to directory at top of directory stack. In this case,
; you are moved back to the original working directory.
POPD
; Display the current working directory and the directory stack.
PRINTD
Windows Examples
In this example, PUSHD is used to change the current working directory. The current working directory is pushed onto the directory stack before moving to the subdirectory. Procedure POPD is used to change the current working directory to the directory at the top of the directory stack. Thus, you are returned to the original working directory. Procedure PRINTD is used to view the current working directory and the directory stack before and after the execution of PUSHD and POPD.
CD, !Dir
; Display the current working directory and the directory stack.
PRINTD
; Push current working directory onto the directory stack, and
; move to the subdirectory \lib\user.
PUSHD, 'lib\user'
; Display the current working directory and the directory stack. 
; Note that the top of the stack contains the previous working
; directory.
PRINTD
; Move to the directory at the top of the directory stack. In
; this case, you are moved back to the original working directory.
POPD
; Display the current working directory and the directory stack.
PRINTD
See Also