CWEEP -- A SWEEP-like program for MS-DOS Page 1 By Gary M. Berg 3707 Silver Oak St Dayton, Ohio 45424 or c/o Chemineer Inc. P.O. Box 1123 Dayton, OH 45401 (513) 454-3213 C.I.S. # 70106,1624 Date: 17-Jan-88 Copyright (C) 1984-87 by Gary M. Berg/Chemineer Inc. Disclaimer This software has been released to the public domain by the author. All commercial rights are retained by the author. It may be freely passed on to others as long as no charge is made except for possibly a small copying charge. Although this software is thought to work as described, no warranty of fitness is made for this software. CWEEP is a program which provides the same capabilities for the MS-DOS user as the program SWEEP does for the CP/M user. It provides the ability to take a sorted list of the files on a disk and move forward and backward in the list. Files can be viewed, copied, deleted individually and in groups. CWEEP is invoked at the MS-DOS command line by: CWEEP {d:}{path}{afn} {-sw} {-sw} {d:} an optional drive letter, the default being the currently logged drive {path} an optional path. Valid only for the 2.x version. {afn} an optional ambiguous filename of what files to look at, the default begin "*.*" (in the currently logged directory under DOS 2.x). {-sw} an optional switch or switches. Switches begin with a '-' character. CWEEP -- A SWEEP-like program for MS-DOS Page 2 CWEEP will then look up all files matching the specified files, and prompt with the first file name. At this point, commands can be entered to move around in the list, tag files, copy files, etc. The display on the next page was generated by starting CWEEP with no filename specified: CWEEP CWEEP version 2.31a as of 17-Jan-88 Copyright (C) 1984-87 by: Gary M. Berg/Chemineer Inc. sp/cr Advance to next file Output list (-+ only) [A] Again tag '#' files (-+) [P] Protected mass copy [B] Back up one file Query files (-+ only) [C] Copy file to drive (-) [R] Rename a file [D] Delete a file [S] Sort directory [E] Erase (un)tagged files [T] Tag a file [F] Free space on a drive [U] Untag a file [H] Hexadecimal display (-+~) [V] View a file (-+~) [I] Inquire file size/time (-+) [W] Wildcard file tag (-+) [J] Jump to a named entry [X] Exit program [L] Log new drive/filename (-+) [Y] Modify attributes (-+) [M] Mass copy tagged files [Z] Change subdirectory(-) [N] Calculate CRC (-+) [!] Goto DOS [?],[/]Print this message [=] Goto settings menu [-?], [+?] other help messages, [@] for printer, [~] for search 55 files, using 1284128 bytes (1283K) -- 1837056 bytes free (1794K) Volume label: Path = 'D:\CWEEP\' 1. D:CWEEP .TXT 03-Nov-1987 32K =[ ] The files matching what was specified (in this case *.*) are sorted in alphabetic order, and the first file in the list is listed on the screen with the date and the size rounded up to the nearest 1K. In addition, the amount of space free and the amount of space used in the selected files is displayed. Note that in the display the period "." following the file sequence number on the left will display as: "r" if the file is read- only, "h" if it is hidden, and "s" if the files is a system file. The colon ":" following the file size will display as an equals sign "=" if the file does NOT have the archive bit set. Thus, we can have displays such as: 1. D:CWEEP .HST 18-Jul-1987 4K :[ ] Read/write, archive on 1r D:CWEEP .HST 18-Jul-1987 4K :[ ] Read-only, archive on 1. D:CWEEP .HST 18-Jul-1987 4K =[ ] Read/write, archive off 1r D:CWEEP .HST 18-Jul-1987 4K =[ ] Read-only, archive off CWEEP -- A SWEEP-like program for MS-DOS Page 3 The characters following a command description on the menu are the allowed prefix characters for that command. For example, the [V]iew command may be prefixed with a '+', '-', or a '~' character, in addition to be used without any prefix character at all. Those commands with a command letter surrounded with '<' and '>', (such as utput), can be used by the prefix characters, but cannot be used by themselves. -------------------------------------- The following is a list of commands with a short explanation: [@] This character may be prefixed to a command to cause the output of the command to also go to the printer. This works with the [?] help, [H]ex, [N] CRC, [Q]uery, and [V]iew commands. If the command is a "paged" display, form-feeds will automatically be added to the printer output every 60 lines, and a page heading will be printed for the view and hex dump commands. [~] This character may be prefixed to the view and hex dump command to cause a search for the "search target" to be done. The search target is entered with "+V" or "+H", as explained below. The ~ may be combined with other prefix characters to get paged view/hex dump output. Advance to the next file on the list. Go to the first file on the list if you are at the last file on the list. [A] Re-tag all files which are marked with a "#" in the list. [-A] Reverse the status of tagged/untagged files. All files which have tags of ' ' are tagged with an '*', and all files with a tag of '*' are tagged with a ' '. All files which are tagged with a '#' (from previous mass copying) are left unchanged. [+A] Set all tags on files to blank (untagged). [B] Back up to the previous file in the list. Go to the last file in the list if B is entered when you are waiting at the first file on the list. CWEEP -- A SWEEP-like program for MS-DOS Page 4 [C] Copy this file to another drive. Prompt for the drive to copy to. Destination drive can be entered in the form "d[:[v]]". The if the "v" is specified, then the copy will be verified. If the file already exists, the user will be queried about whether to delete it or not. In version 2.x, the destination may be given as a subdirectory. The default drive will be the current one. "A" - Copy to drive A "A:" - Copy to drive A "B:V" - Copy to drive B, and verify copy "B:\GARY:V" - Copy to subdirectory "\GARY" on drive B. Verify the copy. "OTHER\SOME:V" - Copy to subdirectory "OTHER\SOME" on the logged drive. Note that this is a relative subdirectory, relative to the current subdirectory on the logged drive. A copy operation may be interupted by hitting a key; the IBM extended keys such as arrows and functions keys will not interupt a copy, however. If the verify operation is interupted, the file is left on disk. [-C] Copy file to another file name. Need to specify what the new drive and file name are. Append a ":V" to the end of the new name if you want the copy verified. Specify the destination subdirectory if required. Wild cards may be used in the output file name if desired, and the characters will be filled in as you would expect. [D] Delete file or subdirectory. You are asked to verify deletion. [E] Erase all tagged or untagged files. User is prompted for which type of files to erase, and whether the user should be prompted about each file or not. At most options an "A" will abort the operation. If the user requests that to be queried on each file the file name and date is listed and a response requested. Valid responses are: Y Yes, erase the file. N No, don't erase this file. Go on to the next one. Leaves the file tagged. V View this file. Displays the same way a View command would, although paging is always used. ! Go to DOS, to let the user do whatever they want. A Abort the erase operation and return to the main menu. [F] Check free space on any drive. [H] Dump the file in hex format one page at a time (affected by paging flag). The escape and return keys abort the dump, any other key pauses it. CWEEP -- A SWEEP-like program for MS-DOS Page 5 [+H] This allows the user to set the search object for a later [V]iew or [H]ex command. When '+H' is entered, the user will be prompted to enter a search object, which will be used to search the file for a starting point before printing or viewing if the '~' is used to prefix a view or hex dump command. This command will NOT cause a search; a normal view or hex dump command (prefixed with a ~) must be used later. The format of the search object is the same as that used by the DEBUG utility to enter a string: strings are surrounded by single quotes ('), and numbers are entered as hex digits. For example: FF FE 'Hello'' there' 00 would look for the sequence of FF(255) FE(254), followed by a string consisting of "Hello' there" followed by a character having the value of 00(0). FF FE Hello' there 00 The "+V" command is interchangeable with the "+H" command. The search string is remembered until it is changed, so multiple searches may be made for the same search string. [-H] Dump the file in hex without pausing. Affected by the paging flag. [I] Display the file size in bytes and the creation time. Also displays the file attributes. [-I] Display the file information on all tagged files. [+I] Display the file information on all untagged files. [J] Jump to the file in the list. Specify name and extension, it will jump to the closest point in the list. [L] Log in a new drive (directory on V2.x) and ambiguous filename. Will replace the list currently being used by one matching what was entered. If no period (".") is in the string, a "*.*" will be appended to the string for the ambiguous filename. [-L] Log in the subdirectory currently displayed. [+L] Log into the directory one higher than where we are. [M] Copy all files which have been tagged to a specified drive. The syntax is the same as for the Copy option. This option WILL delete (without warning) any files existing on the destination if they match a file which is being copied. CWEEP -- A SWEEP-like program for MS-DOS Page 6 [N] Calculate a CRC for this file. This is the same CRC as the CP/M program CRCK returns. [-N] Calculate CRC's for all tagged files. [+N] Calculate CRC's for all untagged files. [-O] Output a list of all tagged files to a disk file. [+O] Output a list of all untagged files to a disk file. [P] Protected mass copy option. Same as "M" option except that the user will be queried before existing files are deleted. If the output file exists, there will be a menu similar to that presented under the queried erase command. The same options apply, including viewing the file and going to DOS. You can view both the input and output files to determine what steps to take. [-Q] Display a list of tagged files. [+Q] Display a list of untagged files. [R] Rename the file to something else. A wildcard new name is allowed. If just "*" is entered, a wild card may be entered for the old and new names. [S] Sort the directory in order by name, extension, date, or size. Preceed the sort field by "-" to invert the normal order. Can be sorted by: n Name and extension e Extension and name d Date s Size t Tag marker # Re-sort by the last specified order [T] Tag a file. It will appear in the listing marked with a "*", and will be used in any operations which work on tagged files. [U] Untag a file. Clears the "*" marker. [V] Display the file a page at a time. It ignores line feeds, and converts returns and vertical tabs to return/linefeed. This allows listing files created by programs which only put returns in the file, such as Spellbinder. The listing can be controlled by using return or escape to terminate, and any other key to pause. If the file is a .WKS, .WRK, or .WK1 file (Lotus spreadsheets), CWEEP will display the contents of the worksheet in a readable form. This displays information about the spreadsheet, including ranges, graphs, and the contents of each cell. CWEEP -- A SWEEP-like program for MS-DOS Page 7 The paging flag controls whether this command pages the display or if -V does. See the documentation on the mini-menu for setting the file viewing program [+V] Set search object. Same as "+H" command. [-V] Display file without paging. Affected by paging flag. [W] Tag all files matching a wildcard. [+W] Untag all files matching a wildcard. [-W] Tag all files not matching a wildcard. In the "W" and "+W" commands, the wildcard may be entered as "wildcard;attributes". The match test will require that the wildcard match and that the file have (at least) the attributes specified in the attribute string. The attribute string is in the same format as in the "Y" command below. Note that matching all attributes specified means that a match will occur if the specified set attributes are on and the specified clear attributes are off. The state of attributes not specified as set or cleared doesn't matter. If a question mark is included in the archive string, then the user will be queried on whether to tag or untag each file. You may also view the file, drop to DOS, tag/untag the rest of the files, or abort the wildcard operation. [Y] Modify the attributes associated with a file. The user will be prompted for attributes to add (+) and subtract (-) for the file. The user can input a string consisting of "+", "-", "a", "r", "h", "s" in any combination. The characters mean: + Set the following attributes. There is an implied "+" at the start of the input, so the default is to set the file attributes entered. - Clear the following attributes. Will remain in effect to the end of the input string or until a "+" is found. a Set/clear the archive bit. r Set/clear the read-only bit. h Set/clear the hidden bit. s Set/clear the system bit. Note that the attributes on a file are NOT copied to a new file by any of the copy commands; the only way to do that is to use the "Y" command to set the attributes. CWEEP -- A SWEEP-like program for MS-DOS Page 8 [-Y] Set/clear attributes for all tagged files. [+Y] Set/clear attributes for all untagged files. [Z] Enter a CHDIR command. Note that this will only change the DOS default directory. It will NOT change the directory which CWEEP has logged. However, now that you have changed the default directory, you can refer to it just a D: instead of having to put out the entire path (unless you are copying to the same drive as the source files are on). [-Z] Create a subdirectory (MKDIR). [?] [/] Print help text for all commands with no "+" or "-" prefix. [-?] [-/] Print help text for all commands with a "-" prefix. [+?] [+/] Print help text for all commands with a "+" prefix. If the display output is paged, then if a "+" or "-" is typed at the "[more]" prompt, the display will be scrolled up a single line and the prompt re-displayed. Using the "+"/"-" with the hex dump is not recommended, since pages are defined in terms of a number of lines, and using the "+"/"-" will shift a page of the hex dump to break in the middle of an address range. CWEEP -- A SWEEP-like program for MS-DOS Page 9 [=] This will take you to a settings menu controlling several program flags. These are: [8] Select whether 8-bit characters are displayed unchanged, or if the 8th bit is stripped off. If 8-bit characters are displayed, only special characters like , , , etc are handled specially, and all others are displayed as text characters. If 8-bit characters are not being displayed, then the 8th bit is removed, and everything outside of the range of 32-127 is considered to be non-printable. [A] Select whether time for the Info command is displayed as AM/PM or 24-hour. The choice is toggled between the two options each time this option is selected. [B] [I] Select how I/O is done. You will be prompted if you want to use Standard DOS, IBM compatible bios, or Z-100 bios to do the output. Using the bios routines will improve the display speed about 33% (IBM) or nearly 50%(Z-100). Note to Z-100 users: if PERKS is brought up while running CWEEP, using the bios I/O gives a jerky scroll until CWEEP is exited again. It's no slower, just strange. I have no explanation. [C] Control clearing the screen while viewing a file. If on, the screen will be cleared each time "[more]" is displayed at the bottom of the screen if a bios I/O method is being used. [H] [S] Control whether or not logging in files on a drive will list files with the hidden and/or system attribute. The normal default is to not display those files. If this ability is turned on, the drive must be re-logged to list any hidden/system files. [M] Turn the menu printing on/off. Turning it off will suppress printing the menu when logging a new file specification. Same as the command line option "-?" or "-/". [P] Turn the paged display on/off. Controls whether the output from the view and hex dump commands will be paged or not by default. If this is active, then "-V" will NOT page the display, and vice-versa. CWEEP -- A SWEEP-like program for MS-DOS Page 10 [V] Turn special viewing on/off. When active, the program named in the environment variable CWEEP:V will be used to display the file, instead of CWEEP's own view routine. This allows using a program such as Vernon Buerg's LIST.COM to page through files. You can set the environment variable by including a command such as: SET CWEEP:V=C:\BIN\LIST.COM in your autoexec.bat file, or from the keyboard. Note that the entire path and full program name MUST be included. This could also be any program that expects the file name on the command line, such as a text editor. [W] Turn on/off extended display of Lotus and Symphony spreadsheets. If on, files with the appropriate extension will be displayed as worksheets. [Z] Turn ctrl/Z processing on/off. When on, viewing a file will stop on ctrl/Z. When off, ctrl/Z is not considered an end of file. [=] [Q] [X] Exit the settings menu and return to normal operations. [?] [/] Print a help message. On IBM-PC compatible computers, the following special keys have meaning: Go to next entry (same as ). Go to previous entry (same as B). Go back 16 entries. Go forward 16 entries. Go to top of list (entry 1). Go to last entry in list. Delete file/directory (Same as D). Create a subdirectory (Same as -Z). Ignored. This allows the user of a mouse driver which produces arrow keystrokes without confusion. A Set file attributes (Same as Y). CWEEP -- A SWEEP-like program for MS-DOS Page 11 COMMAND LINE SWITCHES The following is a list of valid command line switches for CWEEP. They may follow or preceed the file specification to be logged in. [-?] [-/] Toggle the main help menus on/off. If menus are off, the main help menus will only be displayed when requested. This setting may be altered from the mini-menu. [-8] Toggle 8-bit display. Will reverse the current setting for whether 8-bit characters are displayed as is or with the parity bit removed. [-a] Toggle AM/PM or 24-hour time display for the Info command. [-b] [-i] Select the type of I/O routines to use. The switches work as follows (-i and -b are interchangeable): -b IBM Bios on (or off if patched on) -bi Same as -b or -i -bz Z-100 Bios on (or off if patched on) -bs Standard DOS I/O. Only DOS I/O can be redirected from the command line. [-c] Toggle whether the screen is cleared at the beginning of each page of text when viewing to the screen if using a bios I/O method. [-h] Toggle looking up hidden/system files. [-p] Toggle the paged display on/off. [-v] Disable the use of an external file viewing program, if one was specified with a SET command. [-z] Toggle control/Z processing. If present on the command line, control/Z will be ignored when encountered in a file being viewed. This setting may be altered from the mini-menu. [-d] [-e] [-n] [-s] Set the initial sort order to ascending whatever. The options are the same as in the [S] command. If the switch is entered as [--x] then the order will be descending (i.e., [--d] will sort by descending date, or most recent first). CWEEP -- A SWEEP-like program for MS-DOS Page 12 For the user who does not like the default settings of some of the command-line switches in CWEEP (not for the faint of heart), it is possible to patch the values with DEBUG. If you unassemble the beginning of the code, you will find several move word and move byte instructions. By changing the value moved to 1 (true) or 0 (false) the default may be changed (note that sort-order is an ascii character). To do the patching, rename CWEEP.EXE to CWEEP.BIN and type: DEBUG CWEEP.BIN Then, disassemble the beginning of CWEEP by typeing: -u310 l60 DEBUG will then display everything to the right of the patch addr entry in the table below (???? means some address we are not concerned with): Fcn Patch Address Hex code Disassembled instructions Addr ????:0310 33C0 XOR AX,AX ????:0312 E8???? CALL ???? ????:0315 C706????0100 MOV WORD PTR [????],0001 ????:031B C706????0000 MOV WORD PTR [????],0000 ( 1) 325 ????:0321 C706????0100 MOV WORD PTR [????],0001 ( 2) 32B ????:0327 C606????6E MOV BYTE PTR [????],6E ( 3) 330 ????:032C C606????00 MOV BYTE PTR [????],00 ( 4) 335 ????:0331 C606????00 MOV BYTE PTR [????],00 ( 5) 33A ????:0336 C606????00 MOV BYTE PTR [????],00 ( 6) 33F ????:033B C706????0100 MOV WORD PTR [????],0001 ( 7) 345 ????:0341 C706????0100 MOV WORD PTR [????],0001 ( 8) 34B ????:0347 C706????0000 MOV WORD PTR [????],0000 ( 9) 351 ????:034D C706????0100 MOV WORD PTR [????],0001 (10) 357 ????:0353 C706????0000 MOV WORD PTR [????],0000 (11) 35D ????:0359 C706????0000 MOV WORD PTR [????],0000 (12) 363 ????:035F C706????0000 MOV WORD PTR [????],0000 (13) 369 ????;0365 C706????0000 MOV WORD PTR [????],0000 1) Menu display The "M" in the settings menu 01 00 - Menu will be displayed 00 00 - Menu will not be displayed 2) Initial sort order 3) 4) Place the desired original sort order here, using upper case for descending and lower case for ascending sort. Use one character per MOV instruction. The same letters are used as in the set sort command, but the '-'s have been applied to the letters which follow them. 5) Terminates string (Don't change this at all!!) CWEEP -- A SWEEP-like program for MS-DOS Page 13 6) Ctrl/Z handling The "Z" in the settings menu 00 00 - Ignore ctrl/Z 01 00 - Ctrl/Z means EOF 7) Paged display The "P" in the settings menu 00 00 - Unpaged view by default 01 00 - Paged view by default 8) I/O display What display routines to use: 00 00 - Standard DOS (can redirect) 01 00 - IBM Bios 02 00 - Z100 Bios 9) Worksheet display Controls whether worksheets will be displayed in a special manner or not: 01 00 - Special interpreted display 00 00 - As if it was text 10) Clear screen Is screen cleared during viewing (only works if using a bios I/O method): 00 00 - No screen clear after [more]" 01 00 - Screen is cleared after "[more]" 11) Display 8-bit Are 8-bit character displayed as is, or with the 8th bit removed: 00 00 - 8th bit removed 01 00 - 8th bit unchanged 12) Lookup sys/hidden Are system/hidden files found when a disk is logged in: 00 00 - Not found 01 00 - Are found 13) Time AM/PM or 24-hr Is the time for the Info command displayed as AM/PM or 24-hour: 00 00 - 24-hour 01 00 - AM/PM Using the DEBUG "E" command, modify the bytes in each instruction which control the feature desired (at the "patch addr" address). For example, to turn on IBM bios usage, and not display the menu except when requested: E34B 01 00 E325 00 00 The best way to check that you made the changes correctly is to go back and use the "u" command to unassemble the same section of the program and make sure that the only things changed are what you expected to change. If the instructions don't look at all like they used to, you probably placed the code in the wrong location. CWEEP -- A SWEEP-like program for MS-DOS Page 14 When all of the changes have been made, use the "w" command to write the file back to disk, quit DEBUG with the "q" command. Rename CWEEP.BIN back to CWEEP.EXE and try it out. Be sure to test this version where it can't get to any files in case you make a mistake. CWEEP is written in the C language, and compiled with the Microsoft C V5.0 compiler. Development has been done at different times using a Zenith Z-100, Zenith Z-151, and a Multitech Accel 900. Custom routines for reading and writing files and handling all I/O to the keyboard and printer. These avoid the use of the standard I/O library which would increase the size of the program. If the standard DOS I/O routines are used, the output of CWEEP may be re-directed to a file or to the printer. However, the output will not be displayed on the screen, making it rather difficult to use. It is nice for obtaining a copy of the menus in a file, however. CWEEP -- A SWEEP-like program for MS-DOS Page 15 Modification history of released versions: 1.30 Jul 1984 o Original version, supports DOS v1.x directories only. 2.14 Jan 1985 o Supported DOS 2.x subdirectories. 2.30h Dec 1987 o Supported faster display output with bios options. o Lotus Worksheet displayed in the view command. o Reverse default sense of the "-" for display paging. o Added ability to search for text before viewing. o Added CRC of a file option. o External viewing program and ability to go to DOS added. o Larger copy buffer added (63K). o Added ability to go up/down directory trees with the log command. o Display subdirectories in the file list. Can also delete them. o Ability to view files during protected copies and queried erases added. o Display volume label. o Lookup hidden/system files. o Add ability to modify attributes. o Wildcard tag/untag based on attributes. o Display Info on tagged or untagged files. 2.31a Jan 1988 o Support IBM arrow keys, PgUp, PgDn, Home, End, Insert, Delete, A. o Print error if doing a protected copy over an existing subdirectory. o Fix problem with program hanging (need ctrl/C to exit) if doing a protected copy and user tells it to abort or not delete the output file. (Did a close of the stdin handle).