CHKDOC.DO by James Main Kenney 1996 Documentation for CHKALL.BA and CHKSUM.BA, programs to check the identity and integrity of multiple text files. CHKALL.BA and CHKSUM.BA run on the following Kyocera-made notebook computers: Tandy Radio Shack TRS-80 Model 100, Tandy 102, Tandy 200, NEC PC-8201A and NEC PC-8300. These programs display and optionally save to a file the following information about a text (.DO) file in computer RAM: length (number of bytes), full checksum, and a cyclically weighted sum with mnemonics (described below). CHKALL.BA can also provide the same information about files in Booster Pak RAM, on TPDD disks, or on tape. The optional data file is in the same 39-characters/line format as that produced by CHECKALL.BAS or CHECKALL.EXE running under MS-DOS. This data file allows the detection of file changes caused by various factors such as intentional modification, noise during modem transfer without error correction (ASCII transfers), or corruption during storage (which does not usually change the file size). (The Kyocera notebooks do not automatically attach to a file the date and time of last modification, as MS-DOS computers do.) For both programs, the name of a file to be checked can be directly entered or, for CHKALL.BA, 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. (These delimeters may be changed by editing line 4.) An attempt is made to open a file for each "reasonable" name (one to six acceptable characters before a period) that appears on the list, and error trapping is used to recover if the file does not exist in the place specified by the file path. A directly entered filename need not have a period or extension, and may even have an illegal extension. Whether a filename is entered directly or extracted from a file list, the original extension is replaced by ".DO", so that a list of programs with, e.g., .BA or .CO extensions on the filenames may be used to prompt a check of the ASCII text (.DO) versions actually in RAM. This also insures that the names in the data file will always have .DO extensions, for clarity. (CHECKALL, for MS-DOS computers, checks all file types, including Kyocera produced .BA and .CO files.) For either type of filename entry in CHKALL.BA, 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 check at a later date will therefore add data lines only for new or altered files (below a new header, with date and time, etc., where they are easily found). CHKSUM.BA does not check for duplicate data, but is only a third the size of CHKALL.BA. For both programs, 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 programs (.BA and .CO files), the appearance of such characters in a text (.DO) file is unusual, and a possible indication of corruption. The count may be useful to a restoration attempt. Full checksum is the sum of the ASCII values of all the characters (i.e., of all the bytes) in the file, unmodified by MOD or AND (sometimes used to shorten the number). 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 chosen to keep the numbers within the 32K limit for the integer variables required by the AND function. ("AND63" and "AND16383" perform the same functions as "MOD64" and "MOD16384" (16k), respectively, but are faster.) While the length, checksum, or weighted sum can each remain unaltered by certain kinds of file changes, it is highly unlikely that all three will. Operating instructions for CHKALL.BA: ------------------------------------ (Note that the Tandy ENTER key referred to below is equivalent to the NEC hooked-arrow return key.) 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 RAM), enter the name of a file listing the names of files to be automatically checked, or press only ENTER if filenames are to be directly entered at a later prompt. At the third prompt, enter the path (a term borrowed from MS-DOS and used in CHECKALL) for the files to be checked or press only ENTER if they are in computer RAM. If a Booster Pak is attached, enter the path "R:" to check files in Booster Pak RAM. For the 200 KB Tandy Portable Disk Drive 2, enter the path "0:" or "1:" to check disk files in the desired bank (use only "0:" for the original 100 KB TPDD); this requires TS-DOS or the Booster Pak. For a cassette drive (untested), enter the path "CAS:" to check tape files. The colon is optional: CHKALL will append one if the path is entered without it. A caption header will then be displayed above where the 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 (or F8 on a Tandy or SHIFT-f5 on an NEC) to exit to Menu. If a filename is entered, this prompt will reappear after the file is checked (a frequently lengthy process, hence the beep!), 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. After the files are checked there is a beep, and return to Menu is automatic. 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 text 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 file for that exact filename. The message "x bytes > 126" below the data (accompanied by a beep) indicates that there are x number of high 8-bit characters in the file, a warning of possible corruption. Operating instructions for CHKSUM.BA are the same as for direct entry in CHKALL.BA, except that after the first prompt, the direct-entry prompt appears.