Newsgroups: comp.sys.ibm.pc.programmer Path: utzoo!utgpu!watserv1!maytag!watstat!dmurdoch From: dmurdoch@watstat.uwaterloo.ca (Duncan Murdoch) Subject: Re: Current directory from batch file Message-ID: <1990May8.035820.752@maytag.waterloo.edu> Sender: daemon@maytag.waterloo.edu (Admin) Organization: University of Waterloo References: <90122.175401MCCABE@MTUS5.BITNET> <10153.26405d35@vax1.cc.lehigh.edu> <1873@gannet.cl.cam.ac.uk> <90May7.072047edt.19230@me.utoronto.ca> <1990May8.003238.6922@agate.berkeley.edu> <90May7.215707edt.19841@me.utoronto.ca> Date: Tue, 8 May 90 03:58:20 GMT Lines: 38 In article <90May7.215707edt.19841@me.utoronto.ca> sun@me.utoronto.ca (Andy Sun Anu-guest) writes: > >You've told half of the story, but what about the other half? I am >interested in how you create that \usr\lib\cdspace file. I don't know >of any smart way to get this done except by a line of C code: > > main() {printf("cd ");} It's occasionally handy (as here) to be able to echo text without appending a CR/LF, so a few years ago I wrote a tiny 23 byte assembler program to do it. The .DOC file is attached below. Duncan Murdoch ----------------------------- EchoN - Echo command line without going to a new line. by D.J. Murdoch, 13 Nov 1987 This handy little program works like ECHO, but doesn't do a new line at the end. I use it in batch files to save a directory: ECHON cd >\olddir.bat CD >>\olddir.bat This puts the "cd " into the file olddir.bat in the root directory, then lists the current directory into that file on the same line. Executing OLDDIR any time after that puts you back into the original directory. Unlike PUSHDIR and POPDIR, this lasts after you reboot your computer. Here's source code, that could be assembled using DEBUG if ECHON.COM is missing: MOV CL,[0080] ; Put line length into CL SUB CX,+01 ; Subtract 1 to get rid of initial blank JL 0115 ; Quit if there were no characters MOV BX,0001 ; Output to Standard Output... MOV DX,0082 ; from command line, starting at the 2nd char... MOV AH,40 ; using the write service... INT 21 ; do it! INT 20 ; quit