Authors
Publication
Pub Details
Date
Pages
It’s not often that a short piece of new programming can add a whole new dimension to a program, but that’s what happens with this mod. Pro/File the file manager turns into Pro/File the accounts manager with this hot little ditty. Once you add it, you can keep a running total of numbers that you store in files. This makes it possible to use Pro/File to keep track of expenses, costs, accounts receivable, or any application where you need to store numbers and keep running totals. Besides the more mundane business uses, I can see where this program will offer many possibilities in analysis of research data; especially if this enhancement is added to the file count option and the NOT-SEARCH feature. Let me know what you come up with.
Here’s how to use this math function. Add new files so that the number you wish to add appears on the top line immediately next to the asterisk which marks the beginning of the file. Do not put any other information on the top line. Such a file could look like:
*210.98
1-5-85;DEPOSIT
GARAGE SALE
or
*-45.40
1-5-85;TELEPHONE
You can use search commands like the date, or amount of transaction. You could similarly search for an account name like TELEPHONE, or find all your deposits in January by using a multi-word search like “DEPOSIT/I-“.
Regardless of your search command, the number you store on the top line will be added to the total of all the other files which are also found by the search. Numbers can be positive or negative. You can place a decimal point anywhere in the number. If you do not put a number on the top line it will not be added. Neither will a correctly positioned number if it has any other data with it on the same line.
Checks for non-numeric entries are carried out by the program so that in most cases the program will not stop with an error. However, be careful in the way you use decimal points. An entry such as:
*125.00.45
will make the computer rather cranky, and it will stop with an error. If this situation occurs, you must temporarily disable line 156 which caused the error. Then, GOTO 17 to get back into the program and EDIT the fault causing file right away so it won’t cause another error the next time you go to tally it.
One very easy way to disable line 156 is to insert a REM command immediately after the line number. For example:
156 IF N1 THEN LET SUM=SUM+.....
becomes
156 REM IF N1 THEN LET SUM=SUM+...
Anyway, disable the line, EDIT the file that’s causing the error, then remove the REM command to re-enable the line. (Who can find a way to turn the math function off or on under PROGRAM control?)
This enhancement displays the current total with the Display Option Menu. The total up to the last found file is given. You can use the auto-search function to give you just the grand total by telling the computer to print out its data and running through the search with the printer turned OFF. For more information on this read the File-Count option given on page 41 of the manual.
A new Display Option is added with this enhancement to facilitate Lprinting totals. Press “T” (for TOTAL) to print out the sum.
How to Make the Modification
Before I get into the nuts and bolts, I want to thank Joe Rowe, of ARTISAN ELECTRONICS, Box 6631, Portsmouth, VA 23703, for his help in getting me started with this math function. Joe pioneered several methods of number crunching from within ZX Pro/File, and it was his work that fueled my thought on the subject, the results you’re reading now. Joe has several “heavily modified” pro/files which are designed to handle different aspects of his electronics business. He is offering tapes of his “crunchers” at a reasonable price. You might write to Joe to see what he has to offer us ZX/TS nuts.
Now for the nuts and bolts.
First, reduce capacity by about 200 bytes. This means that for 16K, D$ should be redimmed to 10800 characters.
Second, follow the directions in Updates 1:2 for reserving space in D$ for machine code (page 5). By the way, this math routine is compatible with all the other machine code mods given in past Updates.
Third, add the loader program below and GOTO 8000 to input the machine code into DS. Enter the numbers given in the “Poker Table”. Ex: 1, ENTER 0, ENTER, 0, ENTER, 42, ENTER, 123, ENTER, and so on.
8000 FOR X=120 TO 168
8010 INPUT Y
8020 LET D$(X)=CHR$ Y
8030 PRINT Y," ",
8040 NEXT X
8050 STOP
Poker Table
1 140
0 32
0 244
42 201
123 3
64 24
35 230
126 0
254 0
27 0
48 205
8 25
254 65
22 237
40 91
4 123
1 64
0 235
0 237
201 82
254 229
38 193
56 3
5 201
254
Fourth, add these program lines to the Basic listing. After you have the mod working properly, delete the loader program lines (8000 to 8050) to conserve memory.
37 LET SUM=0
150 LET MCD=6+PEEK 16400+256*PEEK 16401
152 LET N1=USR(MCD+119)
154 LET N2=256+USR (MCD+151)
156 IF N1 THEN LET SUM=SUM+VAL D$(N2+1 TO N2+N1)
219 PRINT AT 21,0,SUM
233 IF Y$="T" THEN LPRINT SUM
Finally, GOTO 17 and take ‘er out for a spin. Try adding a few test files and watch how the numbers get processed. What kinds of applications can YOU dream up using this enhancement?