Documentation for DBATCH.BA (D)iskBATCH file driver by Ron Wiesen General DBATCH.BA is a general purpose batch file driver that is specific to the D.CO disk file transfer utility. More accurately, it's specific to a HIMEM protected image of D.CO which is called (D) throughout this documentation. DBDEMO.DO is a batch file that demonstrates DBATCH.BA features. As a consequence of demonstration, DBDEMO.DO is saved on disk. What DBATCH.BA Does When you invoke DBATCH.BA, it lists all files in memory and prompts you for the name of a batch file, such as DBDEMO. If you don't issue any name (only press ENTER), it terminates to the main MENU. If you issue a batch file name (.DO not needed), DBATCH.BA opens the batch file and processes it line-by-line. Empty lines are ignored; command line columns 1 to 11 are extracted as (D) commands, and column 12 and beyond is treated as commentary. As DBATCH.BA extracts each (D) command from the batch file, it loads the Typeahead buffer with: the extracted command a carriage return a Q_Q command to terminate (D) a carriage return. With the batch file remaining open, DBATCH.BA calls (D). The Typeahead buffer is unloaded by (D): first the extracted command which it executes, and then the Q_Q command which terminates (D). Upon return from (D), DBATCH.BA processes the next line in the batch file. When all lines have been processed, DBATCH.DO closes the batch file and restarts itself (lists files and prompt). Batch File Examples A batch file example is shown below. The first four lines manage calendars for years 1996 (LS sequence), 1995, and 1994. The last two lines (KS sequence) backup any notes in memory by saving them on the diskette. 00000000011111111112222222222333333333 12345678901234567890123456789012345678 -------------------------------------- L CAL96 .DOReady for S CAL96 .DOthe New Year. L CAL95 .DO1995 calendar. K CAL94 .DO1994 calendar is obsolete. K NOTE .DOPrior notes are gone, any S NOTE .DOcurrent notes go on Disk. -------------------------------------- Another batch file example is shown below. Its lines relate to a stock market database consisting of an unchanging BASIC program file (INVEST.BA) and recent stock quotations. The stock quotations are kept in the file named QUOTES.DO and its content is frequently changed. Because recent quotations arrive from several sources, they necessarily are entered into QUOTES.DO in any one of three different arrangements. 1. QUOTES.DO exists only in Memory. 2. QUOTES.DO exists only on Disk. 3. QUOTES.DO in Memory is recent while QUOTES.DO on Disk is not recent. The actions of the last three lines (LKS sequence) in the batch file produce a recent change version of QUOTES.DO that is present both in Memory and on Disk. 00000000011111111112222222222333333333 12345678901234567890123456789012345678 -------------------------------------- L INVEST.BAStrategy for Stock Market. L QUOTES.DOAssure recent quotes get K QUOTES.DOin Memory as well as S QUOTES.DOon Disk. -------------------------------------- Sequence and Actions For a given file name, the (D) commands L, K, and S can be applied in 1-, 2-, and 3-command sequences to produce desired actions in memory and on disk. With respect to an initial memory file and disk file arrangement, the chart below shows six command sequences and the actions which each sequence produces as applied to file names: D_______ a file initially on Disk, M_______ a file initially in Memory, V_______ the name of two file Versions: V_(old)_ initially on disk, V_(new)_ initially in memory. +---------------------------+ | INITIAL FILE ARRANGEMENT | | Memory +---------+ Disk | +--------+ +--------+ [ ] [D_______] [M_______] [ ] [V_(new)_] Version [V_(old)_] ========:=============================: SEQUENCE: .ACTIONS. : :in Memory . . on Disk : ========:==========.=======.==========: L :[D_______]..[M_______]: :[V_(new)_].UPDATE=.[V_(new)_]: ........:.............................: LS or SL:[D_______]..[M_______]: :[V_(new)_]. .[V_(old)_]: ........:.............................: KS : . .[ DELETE ]: :[M_______].INSERT>.[M_______]: :[V_(new)_].UPDATE=.[V_(new)_]: ........:.............................: S : . .[D_______]: :[M_______].INSERT>.[M_______]: :[V_(new)_]. .[V_(old)_]: ........:.............................: You can define (D) command sequences and memory/disk file actions in batch files. Read the six descriptions below to identify which sequences you need. For each sequence you need, identify all file names subject to the sequence, that is, the "set of files" for that sequence. When you have identified all needed sequences along with the set of files for each, construct your batch file accordingly. Mistakes happen. Batch file operation minimizes mistakes because all needed memory/disk file actions are performed as one session. Yet, you can make mistakes: use the wrong batch file, or have the wrong diskette in the disk drive. The descriptions below are in order of decreasing "safety" with respect to human error. 1. L__ sequence: load a set of frequently needed or related files (disk to memory). All files of the set which are on disk but are not in memory [D_______], are loaded into memory. All other files remain intact. Safe. 2. __S sequence: save a set of files (memory to disk). All files of the set which are in memory but are not on disk [M_______], are saved onto disk. All other files remain intact. Safe. 3. L_S sequence: interchange sets of files without update. All files of the set which are on disk but are not in memory [D_______], are loaded into memory. All files of the set which are in memory but are not on disk [M_______], are saved onto disk. Any file that is on disk and is in memory [V_______], remains intact in memory [V_(new)_] and intact on disk [V_(old)_]. Safe. 4. LKS sequence: interchange sets of files with update. All files of the set which are on disk but are not in memory [D_______], are loaded into memory. All files of the set which are in memory but are not on disk [M_______], are saved onto disk. Any file that is on disk and is in memory [V_______], remains intact in memory [V_(new)_] and is used as the source for update on disk. Fairly safe. 5. _KS sequence: backup a set of files (memory to disk). All files of the set which are in memory [M_______] [V_(new)_], create or overwrite themselves on disk. Any file that is not in memory [D_______], is killed from disk. Not safe! 6. LK_ sequence: move a set of related files from disk to memory. All files of the set which are on disk but are not in memory [D_______], are moved to memory and killed from disk. Any file that is on disk and is in memory [V_______], remains intact in memory [V_(new)_] and its counterpart [V_(old)_] is killed from disk. Not safe! Files Needed for Installation To install DBATCH.BA, you need the following files in memory: DBATCH.BA - batch file driver for (D) D.BA - loader of D.CO Installation Steps 1. Run D.BA and at the prompt select 0 for D.CO. 2. At the prompt, enter an appropriate End value. Record this (END) value. 3. Issue command LOADM"D. 4. If you did not get an OM? error, go to step 7. 5. Issue command CLEAR256,1-756+(END). 6. Go to step 3. 7. Issue command NEW. 8. Files D.BA and D.CO are no longer needed; KILL them if you wish. 9. Issue command LOAD"DBATCH. 10. Issue command EDIT11. 11. Change EN=62959 to EN=(END) and press the key 2 times. Customizing DBATCH.BA There's nothing sacred about DBATCH.BA in its original form. Change it as you see fit to customize it to your needs. As supplied, the following line ranges exist: 100- Subroutine 30-99 Main routine 20-29 String character constants 10-19 Guards of memory allocation 0-9 general commentary. Subroutine This is heavily commented. Most features are found here so this is where you are most likely to customize DBATCH. Lines 104-105 exemplify use of the Typeahead buffer as an interface between any BASIC program and any machine language program that does not clear the buffer before prompting for keystrokes. Note that line 106 uses TP which depends on lines 11 and 12 in the Guard section. Main Routine Except for line 30, this has no comments. Customization likely will not involve this section. String Character Constants Depending on customization, you may need to expand this section or remove it completely. Guards of Memory Allocation Except for line 10, this section appears heavily commented but unorthodox with each line containing an IF..THENLIST phrase which LISTS its own line number. Where all IF conditions are NOT met, memory allocation probably is correct; execution drops through to the next section. Otherwise, the IF condition that is met first stops execution and the entire line including its "comment" appears on the screen. The "comment" wraps to a separate screen line and serves as an error message. Don't consider removing this section. It prevents cold starts brought about by mistakes we all make. If you just want to reduce the size of DBATCH, replace each IF..THENLIST phrase with IF..THENMENU and delete the remaining portion of each line. That way, you retain the guards but eliminate the "comment" error messages. For certain mistakes, the error messages are misleading anyway. Further reduction in this section should only be done if you fully understand the guards. By all means feel free to increase this section by adding more guards: lines 14-19 are available. Guard line 13 is noteworthy. The PEEK(EN)..OR..PEEK(TP) condition respectively checks the END and TOP of (D) in HIMEM memory. Both of these are absolute values, so they are constant with regard to where (D) was allocated during installation. Should (D) be overlapped by some other machine language program (human error), it's likely that either "side" of (D) changes and unlikely that only the "middle" of (D) is overlapped. The "middle" of (D) is only 754 bytes wide; go figure the odds. If you use lots of "real small" machine language programs, make this guard more robust by extending the OR..PEEK() condition to include one or more "mid points" of (D). Just be sure you pick points that contain absolute values rather than allocation relative values. If you understood the last sentence but can't see how to do it, here's a hint: make and load 2 (D) programs that do not overlap each other and have allocations which differ by an amount other than a multiple of 256.