Switch Directory Stephen M. Falatko Copyright 1987, 1988 Table of Contents Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Available Commands . . . . . . . . . . . . . . . . . . . . . . 3 Acknowledgement . . . . . . . . . . . . . . . . . . . . . . . . 5 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 The Configuration File . . . . . . . . . . . . . . . . . . . . . 8 Caveats and Other Things . . . . . . . . . . . . . . . . . . . . 9 Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . 10 Errorlevel and Batch Files . . . . . . . . . . . . . . . . . . . 11 Changing the Internal Name of SD . . . . . . . . . . . . . . . . 11 License . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Update Notes . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Introduction ------------ Switch Directory - DOS (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 while providing 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. Switch Directory - DOS 1.0 is descended from SD version 3.4 and its predecessors. The improvement in SD is that SD - DOS can attach itself to DOS and provide the same functionality previously only available with SD in combination with PCED or CED. For users of PCED or CED, an enhanced version of SD 3.4 is available called Switch Directory - CED. Available Commands ------------------ [blank] - Display current path \ - Return to root directory \[path] - Switch to the specified path /[subdirectory] - Search below the current directory for 'subdirectory' ? - 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 across drives with the exception of the show path command. SD is NOT case sensitive. + - Loads SD without help. (Using this combination saves almost 1K of memory) - - Loads SD without the stack feature. (Using this combination saves over 600 bytes of memory) 3 d:\dos\sd.cfg - The file is a configuration file for the internal stack. By using a configuration file it is possible to pre-load the stack at startup, making the stack feature much easier to use. The configuration file is an ascii file consisting of ten lines formatted as shown: 0=D:\DOS 1=D:\DOS\TURBO . . The file names can be in any case but MUST include the full drive and path specifier. Each line must be terminated by a carriage return- line feed sequence. Most wordprocessors or text editors can output an appropriate file. If something is wrong with the file SD will let you know. NOTE: The + and - commands can be combined on the command line. The only requirement is that they be immediately after SD. "0 - switch to stack path 0 (the zero may be replaced with any number 0-9) "0=[path] - set stack path 0 to [path]. [path] may contain drive specifiers. In this way you can switch between drives as well as paths. "0=[blank] - clear stack path 0 ([blank] means a space character) "0=@ - set stack path 0 to the current path. "s (or S) - show the current stack contents. "+ - switch to the next available higher stack entry. (for example, if you have switched to stack entry 3, "+ will switch you to the next higher filled entry be it 4, 5, 6... "+ will wrap if none of the higher entries contain paths) "- - switch to the next available lower stack entry. (will wrap around in the same fashion as "+) @ - switch to 'home'. That is, switch to the last directory selected with a "+, "- or "# command. @" - remove SD from memory. 4 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 improvements. Thanks also go to Eric Isaacson, author of A86 for some coding tips. Chris Dunford provided suggestions regarding interactions with PCED and planted the seeds which encouraged me to add the 'stack' feature. Thanks to Jerry Gray for pointing out the problem with subdirectories that have extensions. James Bach gets the thanks for suggesting the hidden subdirectory search. 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 subdirectories 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. 5 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. 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 subdirectories 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) 6 Some of the other available options are SD - SD without any parameters will report the current path. SD + - This command is used when SD is made memory resident. It has the 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 - - Again, this is similar to the previous commands but precludes the use of the internal stack feature. This will reduce the amount of memory SD takes when it terminates and stays resident. SD +- - Here we go again.... This provides the minimum memory configuration for SD. No online help or stack features will be available. NOTE: the order of the + and - is NOT important. SD ? - Provides online help (unless the SD + command has been used) SD "[switch] - The " character provides access to the stack features. These are detailed as follows (remember our directory tree from above) SD "0=\DOS\TURBO\SOURCE SD "1=\DOS\WORDPERF These two lines insert values for stack entries 0 and 1. There are ten stack positions, numbered 0 to 9. A useful tool is SD "2=@ Here, with the @ character, we signal SD to insert the current path into slot 2. This makes it very easy to add paths to the stack on the fly. To clear an entry (make it empty) we simply use SD "3=[blank (space)] It is important to note that when using the "[number]=..... construct COMPLETE PATHS ARE REQUIRED. Drive specifiers are not necessary if the path is on the default drive. SD will insert 7 the drive for you. However, if you put a path on another drive in SD, the drive MUST be specified. To use this feature to switch between drives and paths you simply use SD "0 This would switch you to path 0 (in our case \DOS\TURBO\SOURCE) To get a report on the current status of the stack you can use the 'show' function. SD "s (or S) This provides the following display: Internal Stack: 0 - D:\DOS\TURBO\SOURCE (assumes D is 1 - D:\DOS\WORDPERF default) 2 - 3 - . . 9 - The Configuration File ---------------------- The configuration file provides an effective, simple means to load the internal stack of SD. It can ONLY be used when SD is being enqueued to PCED or CED. The file is an ascii file, that is to say the text is ascii, each line ends with a carriage return and a line feed, and the file ends with a control Z. Most wordprocessors, text editors and even, if you must, EDLIN, can be used. Each line consists of a stack location number, an = sign, and a complete drive and path specifier. An example would be: 0=D:\DOS\TURBO The file can consist of up to 10 stack entries (0 to 9) in any order. An example file, SD.CFG, is included in the ARC file. To use the configuration file you include its name on the command line when enqueueing to PCED or CED. [d:]>SD [p d:\dos\sd.cfg SD will then read you configuration data from the file and put it into the internal stack. No error checking is performed on the 8 specific paths or drives. As long as the configuration file follows the format convention and SD can find it, it will be loaded. If SD cannot find it or it is not in the proper format, an error message will be issued and SD will not become resident. 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 directory program, LDIR and WHISK by Charles Wooster. To this initial base I have added substantial modifications. 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 (202)-547-2008 or Jack Kilday's Northern Lights in Maine (207)-766-2467. 9 Error Messages -------------- The possible error messages are as follows: ERROR - Installed without help This message is displayed if SD is installed with the + command and SD ? is later typed to request help. ERROR - Installed without Stack feature If any of the " commands are entered after SD is installed with the - command this error message will be issued. 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 a subdirectory name, 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. 10 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) SD is already installed When SD begins the installation processes it checks to see if it has already been installed. If it has been installed this error message will be issued. Errorlevel and Batch Files -------------------------- Previous versions of SD worked in batch files. SDDOS does not. If you would like to use SD in batch files then get a copy of SD34 or an earlier version. Changing the Internal Name of SD -------------------------------- When SD is enqueued to DOS, SD must know the command to trap. SD examines every entry at the DOS command prompt for SD (but SD is not case sensitive). When this string is found SD springs into action and processes the request. The string that defines this command begins at offset 296 in the SD.COM file. The string currently contains 'SD' followed by 6 spaces. This string can be edited to contain any name up to 8 characters. The string MUST capitalized and any empty characters MUST be spaces. Upon enqueueing to DOS, SD 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.) 11 License ------- SD DOS 1.0, Copyright (c) Stephen M. Falatko 1987, 1988. ALL RIGHTS RESERVED. (This does not apply to the PrintS or GetDir 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 exchange; and 2) Distribution is WITHOUT ANY modification to the contents of SD.COM and all accompanying documentation and/or support files, including the copyright 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 12 Update Notes ------------ Update Notes for both SD and SD DOS. 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. Version 3.1 - 7/6/87 SD more bulletproof. At the suggestion of Chris Dunford, a PCED 'Kill' command is now 13 recognized and all memory used by SD is deallocated. SD now checks to see if it is installed during installation. Version 3.2 - 8/7/87 Added the directory stack feature. Can now switch between paths by number. Several ways to move between paths and add paths have been included. The stack can be filled when enqueueing to CED (or PCED). Removed the requirement that the [p or [c commands had to be lower case. SD is totally insensitive to case. Added the version and copyright notice printout when enqueueing to CED or PCED. If the notice prints everything is copacetic. Version 3.3 - 9/1/87 Changed the way SD processes a single period (.) on the command line. SD will now recognize search for subdirectory names that include extensions. Thanks to Jerry Gray for pointing out the problem with subdirectories and extensions. Version 3.4 - 11/6/87 SD can now search for hidden directories. Thanks to James Bach for the suggestion. SD DOS 1.0 - 1/22/88 SD DOS attaches directly to DOS. In this configuration, all the features previously only available with PCED or CED are now available without PCED or CED. To remove SD DOS from memory a new kill command ( SD @") has been added as well as a home command (SD @). 14