home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1879 / pushd.com < prev    next >
Encoding:
Text File  |  1990-12-28  |  819 b   |  28 lines

  1. $! pushd.com - push directory onto stack
  2. $
  3. $ if f$type(dir_stack) .eqs. "" then dir_stack :== ""
  4. $ if p1 .eqs. "" then p1 = f$logical("sys$login")
  5. $
  6. $! check that new directory exists (derived from cd.com)
  7. $
  8. $ dir = f$parse(p1,,,"DIRECTORY") - "[" - "]"
  9. $l1:
  10. $  n = f$locate(".", dir)
  11. $  if n .ge. f$length(dir) then goto l2
  12. $  dir = f$extract(n + 1, 999, dir)
  13. $  goto l1
  14. $l2:
  15. $ dir = p1 - "]" + ".-]" + dir + ".dir"
  16. $
  17. $ if f$search(dir) .nes. "" then goto OK        ! look for directory
  18. $ if f$trnlog(p1 - ":") .nes. "" then goto OK        ! try logical name
  19. $  write sys$output "Directory ", p1, " does not exist"
  20. $  exit
  21. $OK:
  22. $
  23. $ here = f$environment("default")        ! push directory on stack
  24. $ dir_stack == here + " " + dir_stack
  25. $ set def 'p1                    ! change to directory
  26. $ if f$type(dirs) .eqs. "" then dirs :== show default
  27. $ dirs
  28.