HFISCHER%USC-ECLB%SRI-NIC@sri-unix.UUCP (01/04/84)
I am submitting another utility for batch files, bat-cd, for the INFO-IBMPC library. This program allows a batch file to change directories (just like the CD command), but to read the new directory from the "standard input file" instead of the command line. The command: bat-cd reads new directory from keyboard bat-cd < file reads new directory from "file" bat-cd <file >nul no display of new dir name when changing You can use the directory changer to change back to the directory a batch file started out with, such as when doing a spelling correction or fancy font printing. . . (your batch file to do fancy font from any directory) . echo off cd > \bin\bat\starting.dir saves initial directory copy %1 \fancyfnt\temp/v make file local to pfont dir cd \fancyfnt go to pfont dir pfont +fi temp +fo romn12 (etc.) do printing del temp get rid of local file copy bat-cd <\bin\bat\starting.dir >nul return to user's directory echo on If you were going to, for example, a speller directory, which made changes to the file, then you would copy the local file back before changing directories back: echo off cd >\bin\bat\starting.dir save initial directory copy %1 \speller\temp.txt/v make your file local cd \speller spellit temp.txt bat-cd <\bin\bat\starting.dir >nul change back to user's dir copy \speller\temp.txt %1/v copy spelling corrected file del \speller\temp.txt back & delete other copy echo on Note that the new input is read as a single line, without any prompt, followed by a carriage return. If the input is not a valid directory, then the message "path not found" is placed on the standard output file (console, but redirectable if one wishes). Herm Fischer attachment: bat-cd.asm ********************************************************************* page 64,132 title bat-cd -- Batch file Directory Changer .RADIX 10 ; ; ; ;***************************************************************** ; Public domain program by H. Fischer - HFischer@eclb 12/83 ; Questions/problems to HFischer@eclb (213/902-5139). ; ; This program allows a batch file to change directories ; (just like the CD command), but to read the new directory ; from the "standard input file" instead of the command line. ; The command: ; ; bat-cd reads new directory from keyboard ; bat-cd < file reads new directory from "file" ; bat-cd <file >nul no display of new dir name when changing ; ; You can use the directory changer to change back to the ; directory a batch file started out with, such as when ; doing a spelling correction or fancy font printing. ; . ; . (your batch file to do fancy font from any directory) ; . ; echo off ; cd > \bin\bat\starting.dir saves initial directory ; copy %1 \fancyfnt\temp/v make file local to pfont dir ; cd \fancyfnt go to pfont dir ; pfont +fi temp +fi romn12 (etc.) do printing ; del temp get rid of local file copy ; bat-cd <\bin\bat\starting.dir >nul return to user's directory ; echo on ; ; If you were going to, for example, a speller directory, which ; made changes to the file, then you would copy the local file back ; before changing directories back: ; ; echo off ; cd >\bin\bat\starting.dir save initial directory ; copy %1 \speller\temp.txt/v make your file local ; cd \speller ; spellit temp.txt ; bat-cd <\bin\bat\starting.dir >nul change back to user's dir ; copy \speller\temp.txt %1/v copy spelling corrected file ; del \speller\temp.txt back & delete other copy ; ; Note that the new input is read as a single line, without ; any prompt, followed by a carriage return. If the input ; is not a valid directory, then the message "path not found" ; is placed on the standard output file (console, but redirectable ; if one wishes). ; ; To build this program: ; 1) asm bat-cd ; 2) link bat-cd ; 3) exe2bin bat-cd.exe \bin\bat-cd.com (name your path dir!) ; 4) del bat-cd.exe ; ;******************************************************************** code segment para assume cs:code org 100h CD proc far START: mov ax,cs ; make this mess addressable via ds mov ds,ax assume ds:code mov dx,offset buffer mov ax,0c0ah int 21h ; read the new directory name mov bh,0 ; stuff a zero at the end mov bl,buflen ; of the name just read mov entry[bx],bh mov dx,offset entry mov ah,3bh int 21h ; change the directory cmp ax,3 ; error code? jne done mov dx,offset error ; display error if bad path mov ah,9 int 21h done: int 20h buffer db 64 ; longest path is 63 chars & c/r buflen db 0 ; dos-read length entry db 64 dup(0) ; the new directory name error db 'path not found',10,13,'$' saveit db 0 CD endp code ends end start -------