Switch Directory 3.0 June 15, 1987 Introduction ------------ Switch Directory (SD) is a utility that allows easy switching between subdirectories and drives with a minimum of typing. SD has been designed to replace the DOS CD command and provide enhancements to the CD command. SD allows you to specify a specific subdirectory name, a combination of subdirectory names and search switches or a complete path specifier. All features of SD work across disk drives. If you have made a mistake, hitting Ctrl-Brk while SD is searching will break you out of SD and put you back in the subdirectory you started in. With version 3.0 SD will also except a 'minimum match' to a subdirectory name (i.e. if you have only one directory that begins with 'LO' then SD LO will take you there even if the full name is LOTUS). Given a full path designation, SD switches to the specified path without searching. An important feature of SD is that it can be enqueued to PCED, the DOS Command EDitor by Chris Dunford and its public domain counter part CED. When enqueued SD will seem like an extension of DOS. In this configuration SD does NOT have to be present anywhere on your disk drives. Begining with version 3.0, issuing a type sd.com at the DOS prompt will report the version number. Available Commands ------------------ [blank] - display current path \ - return to root directory \[path] - switch to the specified path /[subdirectory] - search below the current directory for 'subdirectory' [c - enqueue SD to CED ('c' must be lowercase) [p - enqueue SD to PCED ('p' must be lowercase) [p+ - enqueues SD to PCED but do not provide help. (Using this combination saves almost 1K of memory) (use [c+ for CED) ? - display help information (if not installed with the [+ command) .. - back up one directory Combinations of \ and / may be used to increase the speed of searching while still reducing the required typing. All commands work accross drives with the exception of the show path command. SD is NOT case sensitive (except for SD [c or [p) 1 Switch Directory 3.0 June 15, 1987 Acknowledgement --------------- I would like to thank Jack Kilday, sysop of Northern Lights BBS in Maine for his efforts Beta testing SD and his ideas for improve- ments. Examples -------- Suppose your hard disk directory looked something like this: [Root]------DOS---|---DISKUTIL | |---TURBO--|--SOURCE | | | |--TOOLS | |---WORDPERF Then, if we wanted to switch to this drive we could use: SD d: - would change the active drive to d: and put you in the default directory which we will assume is the [Root] directory (this is similar to typing d: at the DOS prompt) Now that we are in the [Root] directory, lets switch to the TURBO subdirectory. SD /TURBO - would search [Root] for subdirectories and would find DOS. SD would then search the DOS subdirectory for the TURBO subdirectory. The actual search pattern would be to search DOS, find DISKUTIL, search it, find no subdirec- tories so back up to DOS. Then recommencing the search in DOS, SD would find TURBO next and change to that subdirectory. You should note that in our example, since the TU of TURBO is unique we could have used SD /TU with the same results. Now, to go back to DOS we have two options, the first is SD \DOS - In this case SD would recognize the path specifier and search the command line for the complete path specification. Upon finding the end of the line SD would call DOS with the \DOS pathname, which in our case is valid, so we would be taken to DOS. In the case of pathnames the complete path MUST be specified. Please note that this is different from the last example with the minimum matching. 2 Switch Directory 3.0 June 15, 1987 Our second option for returning to the DOS subdirectory is to use SD .. - This command 'backs up' one directory. In our case that happens to be the DOS directory. We could use this command again to back up to the [Root] directory or we could use SD \ - Which switches us to the [Root] directory. If we wanted to do more complex searching to search a large hard disk with many levels of subdirectories we might want to type a 'short hand' version of the complete path to facilitate the search and increase speed. To switch to the TOOLS subdirectory we could use SD /TURBO\TOOLS - This would search below the [Root] directory for the TURBO directory. Upon finding the TURBO directory, SD would execute a switch to the current path plus the \TOOLS. (i.e. SD calls DOS for the current path then appends the \TOOLS to that path. If this combination is valid then the change occurs.) As a reminder, remember that SD /TU\TOOLS would also be valid. Now we could also get to the tools directory by simply using SD TOOLS - With this syntax SD would search the current directory for a TOOLS subdirectory and then, if it was not found, would search the entire disk for a TOOLS directory. With this type of command SD provides the most convenience but the price is speed of switching directories. On a large hard disk with 30 to 40 subdirec- tories the search can take up to 5 seconds. However, as our previous examples show, we can add some more specifications to the search and it will speed up considerably. (Again, SD TO would also be correct) Some of the other available options are SD - SD without any parameters will report the current path. SD [c - This will enqueue SD to CED, the Command EDitor by Chris Dunford, virtually making SD an extension of DOS. In such a configuration the SD.COM file does not have to be present on any of your disk drives. 3 Switch Directory 3.0 June 15, 1987 SD [c+ - This is the same as the last command with the added effect of not providing online help. This can be used to reduce the amount of memory SD takes when it terminates and stays resident. SD ? - Provides online help (unless the SD [+ command has been used) Caveats and Other Things ------------------------ Caveats first. If you have duplicate subdirectory names and do not specify a path but merely let SD search, SD will drop you in the first matching directory it finds. SD will only search the drive that is specified. Currently, SD is limited to subdirectory trees less than ten deep. This limit is arbitrary and could be changed by reassembling SD. The source was initially derived from Vern Buerg's sorted direc- tory program, LDIR and WHISK by Charles Wooster. To this initial base I have added many modifications. The 'FindCED' procedure was provided by Christoper J. Dunford as part of the PCED package. Information on PCED can be obtained from: The Cove Software Group Post Office Box 1072 Columbia, Maryland 21044 (301) 992-9371 The code is written for the A86 assembler. This shouldn't be a problem for anyone who is using MASM. If you have any comments, suggestions or bug reports drop me a line on Bob Blacher's Computer Connection in DC or Jack Kilday's Northern Lights in Maine. 4 Switch Directory 3.0 June 15, 1987 Error Messages -------------- The possible error messages are as follows: ERROR - Installed without help This message is displayed if SD is installed with the [c+ command and SD ? is later typed to request help. Illegal drive specifier - must be A to z If SD finds a ':' character on the command line that is not preceded by a letter it will issue this message. Maximum of 64 characters on command line The command line is limited to 64 characters. If SD counts more than this it will issue this error. Illegal character on command line If a period that is not part of the SD .. command, or the enqueue character ([) is found in any place but the first on the command line, SD will issue the illegal character error message Currently in root directory If the SD .. command is entered from the [Root] directory the SD issues this message Command line contains an invalid path If any invalid path command is entered SD will issue this message. An invalid path can be caused by several things. It can be due to an illegal character (such as < or >) in the pathname, by a / command followed by a \ command, where the \path is not an immediate subdirectory of the directory the / command found or simply by entering a path that does not exist. Subdirectory Not Found If SD cannot find the desired subdirectory it will issue this message. The subdirectory may not exist on the drive at all or it may not be a subdirectory of the current directory (if a / command was issued) 5 Switch Directory 3.0 June 15, 1987 Errorlevel and Batch Files -------------------------- SD can be used from inside batch files. To facilitate its use in this environment SD returns error codes that can be read with the Errorlevel command in batch files. Error levels are only returned when SD is NOT enqueued to CED or PCED. The error levels are as follows: 0 - No errors detected 1 - Illegal drive specifier 2 - Maximum of 64 characters on command line 3 - Illegal character on command line 4 - Currently in root directory 5 - Command line contains an invalid path 6 - Subdirectory Not Found 7 - Error attempting to enqueue to PCED 8 - Error attempting to enqueue to CED Changing the Internal Name of SD -------------------------------- When SD is enqueued to PCED, (or CED) PCED must know the command to trap. SD informs PCED that whenever SD is typed at the DOS prompt to intercept the command line and pass it to SD. The string defining the name PCED is to look for begins at offset 0D41 in the SD.COM file. The string currently contains 'sd' (PCED and CED are not case sensitive) followed by a carriage return and 6 null bytes (zeros). This string can be edited to contain any name up to 8 characters. The string MUST be terminated by a carriage return (hex 0D). Upon enqueueing to PCED, PCED will recognize this new name you have created and will no longer recognize SD. (However, if you change this internal name and do not change the name of the SD.COM file, typing SD at the DOS prompt will work but you will not be accessing the memory resident code you will be accessing the program on disk.) 6 Switch Directory 3.0 June 15, 1987 License ------- SD 3.0, Copyright (c) Stephen M. Falatko 1987. ALL RIGHTS RESERVED. (This does not apply to the PrintS, GetDir or FindCED procedures) SD is free, but it is a copyrighted work and may be distributed only pursuant to this license. Permission is hereby granted to reproduce and disseminate SD so long as: 1) No remuneration of any kind is received in ex- change; and 2) Distribution is WITHOUT ANY modification to the contents of SD.COM and all accompanying documen- tation and/or support files, including the copyri- ght notice and this license. No copy of SD may be distributed without including a copy of this license. Any other use is prohibited without express, written permission in advance. Stephen M. Falatko 311 Wilkes Street Alexandria, Virginia 22314 7 Switch Directory 3.0 June 15, 1987 Update Notes ------------ Version 1 - 3/12/87 Version 1.1 - 3/18/87 Bug fix. An error in the routine that creates a full path name for use in actually setting path would preclude switching to directories whose depth was greater than 2 deep. Version 2.0 - 5/15/87 Changed the path search routine. Added new features, the / and \ switches to search one path deep and search only subdirectories of the current directory respectively. This provides a means to refine the searching and provide more speed. You can now search other drives by specifying a drive on the command line. Added break out feature so that hitting Ctrl-Brk will place you in your original directory. Version 2.1 - 5/19/87 Jack Kilday, sysop of Northern Lights in Maine, suggested that the capability to designate a specific path be added to SD. This has been added. SD recognizes a full path on the command line (by seeing two or more '\' characters) and instead of searching the entire disk for the subdirectory explicitly changes to the desired path. Version 2.2 - 5/21/87 Bug fix. Capital drive specifiers caused and error in the drive switch routine. Version 3.0 - 6/15/87 Added PCED/CED enqueue option, the ability to do multiple level searches and the ability to do minimum match searches. Improved the error reporting to reflect the new capabilities. Changed the handling of a single '\' character as well as the handling of a change drive command. Added the path report if command line blank. 'type sd.com at the DOS prompt now reports the version number. Again, many of the improvements were suggested by Jack. 8