home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast.iso / batutil / batcd.asm < prev    next >
Assembly Source File  |  1994-03-04  |  4KB  |  117 lines

  1.     page 64,132
  2.     title bat-cd -- Batch file Directory Changer
  3. .RADIX 10
  4. ;
  5. ;
  6. ;
  7. ;*****************************************************************
  8. ; Public domain program by H. Fischer - HFischer@eclb 12/83
  9. ; Questions/problems to HFischer@eclb (213/902-5139).
  10. ;
  11. ; For DOS 2.0 and later....
  12. ;
  13. ; Modified by M. D. Parker -- 1/4/84
  14. ;    This program had a little defect in that the default drive
  15. ;    was not reset after this program was used.
  16. ;    This version of the program will make the supplemental
  17. ;    change drive call after a successful chmod DOS call.
  18. ;
  19. ;    NOTE- The first character for CD output is used for
  20. ;    obtaining the drive designator.  The program ASSUMES
  21. ;    this is capitalized!
  22. ;
  23. ; This program allows a batch file to change directories
  24. ; (just like the CD command), but to read the new directory
  25. ; from the "standard input file" instead of the command line.
  26. ; The command:
  27. ;
  28. ;    bat-cd        reads new directory from keyboard
  29. ;    bat-cd < file    reads new directory from "file"
  30. ;    bat-cd <file >nul  no display of new dir name when changing
  31. ;
  32. ; You can use the directory changer to change back to the
  33. ; directory a batch file started out with, such as when
  34. ; doing a spelling correction or fancy font printing.
  35. ;   .
  36. ;   .    (your batch file to do fancy font from any directory)
  37. ;   .
  38. ;   echo off
  39. ;   cd > \bin\bat\starting.dir        saves initial directory
  40. ;   copy %1 \fancyfnt\temp/v        make file local to pfont dir
  41. ;   cd \fancyfnt            go to pfont dir
  42. ;   pfont +fi temp +fi romn12 (etc.)    do printing
  43. ;   del temp                get rid of local file copy
  44. ;   bat-cd <\bin\bat\starting.dir >nul    return to user's directory
  45. ;   echo on
  46. ;
  47. ; If you were going to, for example, a speller directory, which
  48. ; made changes to the file, then you would copy the local file back
  49. ; before changing directories back:
  50. ;
  51. ;   echo off
  52. ;   cd >\bin\bat\starting.dir        save initial directory
  53. ;   copy %1 \speller\temp.txt/v     make your file local
  54. ;   cd \speller
  55. ;   spellit temp.txt
  56. ;   bat-cd <\bin\bat\starting.dir >nul    change back to user's dir
  57. ;   copy \speller\temp.txt %1/v     copy spelling corrected file
  58. ;   del \speller\temp.txt          back & delete other copy
  59. ;
  60. ; Note that the new input is read as a single line, without
  61. ; any prompt, followed by a carriage return.  If the input
  62. ; is not a valid directory, then the message "path not found"
  63. ; is placed on the standard output file (console, but redirectable
  64. ; if one wishes).
  65. ;
  66. ; To build this program:
  67. ;    1) asm bat-cd
  68. ;    2) link bat-cd
  69. ;    3) exe2bin bat-cd.exe \bin\bat-cd.com (name your path dir!)
  70. ;    4) del bat-cd.exe
  71. ;
  72. ;********************************************************************
  73. code    segment para
  74.     assume    cs:code
  75.     org    100h
  76. CD    proc    far
  77. START:
  78.     mov    ax,cs        ; make this mess addressable via ds
  79.     mov    ds,ax
  80.     assume    ds:code
  81.     mov    dx,offset buffer
  82.     mov    ax,0c0ah
  83.     int    21h        ; read the new directory name
  84.     mov    bh,0        ; stuff a zero at the end
  85.     mov    bl,buflen    ;   of the name just read
  86.     mov    entry[bx],bh
  87.     mov    dx,offset entry
  88. ;
  89. ; now lets do the CD command
  90. ;
  91.     mov    ah,3bh
  92.     int    21h        ; change the directory
  93.     cmp    ax,3        ; error code?
  94.     jne    done
  95.     mov    dx,offset error ; display error if bad path
  96.     mov    ah,9
  97.     int    21h
  98. done:
  99. ;
  100. ; first lets change the default directory back
  101. ;
  102.     mov    dl,entry    ;get first character from input
  103.     sub    dl,'A'          ;NOTE- must be capital letter
  104.     mov    ah,0eh        ;command to DOS for default changing
  105.     int    21h        ;call DOS to do the dirty work
  106.     int    20h        ;nightie night to this program
  107.  
  108. buffer    db    64        ; longest path is 63 chars & c/r
  109. buflen    db    0        ; dos-read length
  110. entry    db    64 dup(0)    ; the new directory name
  111. error    db    'path not found',10,13,'$'
  112. saveit    db    0
  113. CD endp
  114. code ends
  115. end start
  116.  
  117.