CHECKALL.DOC by James Main Kenney 1996 Documentation for CHECKALL.BAS and CHECKALL.EXE, programs to check the identity and integrity of multiple files. CHECKALL.BAS will run under either GW-BASIC, supplied with MS-DOS 3 and 4, or QBASIC, supplied with MS-DOS 5 and 6. CHECKALL.EXE will run directly under MS-DOS/Windows; it is a compiled version of CHECKALL.BAS which runs faster and does not require a BASIC interpreter. The compiler was PowerBASIC 2.10g. A Windows icon, CHECKALL.ICO, has been created for use with CHECKALL.EXE. CHECKALL displays and optionally saves to a file the length of each file (number of bytes), its full checksum, and a cyclically weighted sum (described below). The optional data file is in the same 39-characters/line format as used by CHKALL.BA and CHKSUM.BA in Kyocera notebooks. CHECKALL can check files in any directory on any drive. The name of a file to be checked can be directly entered, or the name of a file listing the names of files to be automatically checked can be entered; this file list need not have a special format, but for a filename to be recognized as such it must have a period (even if it has no extension) and its ends must be delimited by characters not used in filenames, such as spaces, parentheses, quotes, slashes, or punctuation marks (even extra periods). (These delimiters may be changed by editing line 5 of CHECKALL.BAS. CHECKALL.EXE cannot be directly altered: a new version must be produced by recompiling CHECKALL.BAS after editing.) An attempt is made to open a file for each "reasonable" name (one to eight acceptable characters before a period and up to three after it) that appears on the list, and error trapping is used to recover if the file does not exist in the directory specified by the file path. A special feature is the optional trial of alternative extensions when the filename with the original extension was not found or, as another option, even if it was; this allows files to be found whose extensions may have been changed from those in the list, or forgotten by the user, or merely for faster and easier entry. The list of extensions is easily modified by editing the DATA statement on line 12 in CHECKALL.BAS. Once use of the alternative extensions has begun, they are all automatically tried, regardless of success, so that the sequence of extensions will not prevent a second valid alternative extension being tried. CHECKALL was created to allow the easy identification of differing copies of files created using older computers, such as the Kyocera notebooks, which do not automatically provide the time and date of last modification. CHECKALL can detect deliberate modifications or unintended changes due, e.g., to noise during modem transfers made without error correction (ASCII transfers) or to corruption during storage. It can provide data on any MS-DOS file, regardless of origin, if the file is shorter than 32768 bytes (32 KB), so as not to overflow the integer limits for program variables. (Larger files with .EXE extensions can be checked, but their lengths are not properly measured.) If the filenames and data are being filed (a data file having been named), and if a data line exactly duplicates a line already in the data file, then the new line is not appended. Repeating the file check at a later date will therefore add data lines only for new or modified files (below a new header, with date and time, etc., where they are easily found). Using CHECKALL.BAS, the file with the names of files to be checked cannot be the same file to which data is appended; using CHECKALL.EXE, however, the same file may be used for both purposes. As an additional check on file corruption, data on the screen or in the data file for a file containing high 8-bit characters (bytes 128 - 255) or byte 127 is marked underneath "x bytes > 126", where x is the number of such characters in the file. Although normal for executable programs and tokenized basic files, the appearance of high 8-bit characters in ASCII text files is unusual and a possible indication of corruption. The count may be useful to a restoration attempt. CHECKALL measures full checksum: the total of the ASCII values of all the characters (i.e., all the bytes) in the file, without modification by MOD or AND (sometimes used to shorten the number). The checksum is insensitive to transpositions or other permutations, i.e., the characters can be interchanged or otherwise moved around without changing the checksum. To detect most permutations, a cyclically weighted sum is also produced: each byte (ASCII value) is multiplied by an integer that increases in unity steps from 1 to 64 and then starts over at 1, and the products are summed modulus 16K. These parameters were selected to keep the numbers within the 32K limit for the integer variables required by the AND function. ("AND 63" and "AND 16383" perform the same functions as "MOD 64" and "MOD 16384" (16K), respectively, but are faster.) While the length, checksum, or weighted sum can each remain unaltered by certain types of file changes, it is highly unlikely that all three will. Operating Instructions: ---------------------- At the first prompt, enter the name of a file to which the data will be appended, or press only ENTER if a permanent record is not desired. At the second prompt (which follows a display of the files in the current directory), enter the name of a file listing the names of files to be automatically checked, or press only ENTER if the filenames are to be directly entered at a later prompt. At the third prompt, enter the path for the files to be checked, or press only ENTER if they are in the same directory as CHECKALL.EXE (or GW-BASIC or QBASIC running CHECKALL.BAS). The final backslash is optional: CHECKALL will append one if the path is entered without it. Finally, press a single key (upper or lower case) to select one of the following extensions options: * Press key N ("Never") to try to open the files using the filenames with their original extensions as they appear in the list file or are directly typed. * Press key A ("Always") to try to open the files using all of the alternative extensions regardless of whether or not trying to open with the original extension was successful. * Press key O, ("Only") or ENTER, or any other key except N or A, to use the alternative extensions only if an attempt to open with the original extension was unsuccessful. A caption header is then displayed above where the formatted data will appear, and is also printed to the data file (below date, time, list filename, and file path) if one was named at the first prompt. If no list file was named at the second prompt, the direct-entry prompt "File to check?" will now appear; enter a filename or press only ENTER to exit CHECKALL. If a filename is entered, this prompt will reappear after the file is checked, facilitating rapid entry of the next filename. If a list file was named at the second prompt, the automatic checking of files whose names are extracted from the list will now start, the results of which are displayed ("pause" to examine in detail). For either the direct or automatic entry of filenames, the message "(file not in path)" will appear on the screen in place of data for names not corresponding to existing files in the selected path. The message "(duplicate line)" below a line of data indicates that this line was not appended to the data file because an exact duplicate is already in the data file for that exact filename. The message "x bytes > 126" below a line of data indicates that there are x number of high 8-bit characters in the file, a warning of possible corruption if it is an ASCII text file. After the search for potential filenames in the list file is complete, information about the run is presented so that it is not necessary to exit CHECKALL to examine the data file prior to a rerun. Press a single key (upper or lower case) to select one of the following terminal options: * Press key L ("List") to rerun, prompted to change only the file listing the names of the files to be checked, but leaving their path unchanged. * Press key P ("Path") to rerun, prompted to change only the path for the files to be checked, but using the same list file. * Press key B ("Both") to rerun, prompted to change both the list file and the file path. * Press key E ("Exit") or ENTER, or any other key except L, P, or B, to exit CHECKALL. Pressing key P also allows the extensions option to be easily changed if no entry was previously made at the path prompt: after pressing key P, press only ENTER to reach the extensions option prompt.