Classic Computer Magazine Archive ANTIC VOL. 2, NO. 6 / SEPTEMBER 1983

TAPE TOPICS

Cardfile for Cassettes

Low overhead data-base program

by VERN MASTEL

The Electro-Cardfile is a handy data-base filing program for ATARI users with cassette recorders. It is written in BASIC and requires only 16K of RAM.

How many times have you seen an advertisement for a new piece of record-keeping software and wanted it, only to be frustrated by high memory requirements or the need for a disk drive? Having been frustrated myself, I wrote this simple program to take care of my simple data filing and storage needs on cassette.

Electro-Cardfile allows you to process 30 file cards of information. Each card has a title up to 15 characters in length and information on the card is organized in 10 lines, each 30 characters long. You can title, fill, view, delete, or modify information on any card you choose. An elementary search routine is also provided to allow you to rapidly locate specific information. At any point during usage, you can store the entire card file to tape for future retrieval. And you may optionally use a 40- or 80-column printer to provide hard copy.

Program logic is actually quite simple. The program builds two strings, one containing card titles (SA$) and another containing card data (CD$). As you enter titles or card data, the program calculates the proper position in the string for this information and then places it appropriately. After you have entered or edited these data strings, Electro-Cardfile stores them for you onto cassette tape.

The program's search option is elementary but effective. While it does not search through all of your data, it does compare the beginning of each line of every card to a specified search key. Say you have a list of business contacts in your file and you want to find "Insurance Agents" (your search key). Electro-Cardfile will locate a line beginning with "Insurance Agents Names and Addresses." It will not, however, locate "Allied Insurance Agents." The search key (up to 30 characters long) must identically match the first characters of a line.

I wrote this program to get the most powerful program into the least amount of memory. There are no REM statements. I replaced off-repeated numbers such as 1 and 30 with variables. And I have packed all program lines as fully as possible. An advantage to packing commands on as few statement lines as possible is increased speed of execution! I also placed all calculation subroutines at the head of the program, also to improve execution speed.

PROGRAM CODE

Lines 10 through 50 dimension strings and assign values to variables. Using READ/DATA statements to assign values to variables requires less memory space than assigning values with the actual or implied LET command and the " = " sign.

Lines 100 through 160 contain calculation routines for string position as well as input range checks. Line 100 finds the starting and ending points of the title for a given card. Line 110 finds the starting point of the data for a given card. Line 120 finds the location of a specific line of data on a given card (used when you enter or modify data on a card). Line 130 handles data and title strings when loading from or saving to the cassette recorder. Line 140 clears the screen. Lines 150 through 159 check all keyboard input to make sure it is within expected ranges. Bad keyboard input automatically returns you to the menu. Line 160 fills the unused portion of card data lines with blanks.

Line 500 is the printer routine. You may opt to dump the contents of a card to a printer for hard copy. Lines 1000 through 1030 manage title input and positioning in the title string. Lines 2000 through 2010 list all of the card titles to the screen. Lines 3000 through 3060 manage card data input and positioning of data in the card data string. Lines 4000 through 4040 are used to modify your data entries on any card in the file.

Lines 5000 through 5020 are used to delete a card from the file by overwriting its contents with blanks. Lines 6000 through 6050 display the contents of a selected card. Lines 7000 through 7020 and 8000 through 8020 manage SAVE and LOAD options to and from the cassette recorder. Lines 9000 through 9030 operate the card data search routine. Lines 10000 through 10020 display the menu and allow you to input your selection.

When you first RUN Electro-Cardfile you will see a menu which offers nine options. If you selected Title, Fill, View, Delete or Modify and then change your mind, you can enter the value "50" for a card or line number to return to the menu. Unacceptable line or card numbers automatically return you to the menu. When you enter titles or card data you are limited respectively to 15 and 30 character maximums. Additional input on the line is ignored.

OTHER DETAILS

Cassette users will note the unusual structure of the OPEN commands on lines 7000 and 8000. The auxiliary code which is normally zero has been changed to 128. This shaves about 30% off the time needed to LOAD or SAVE a complete card file. The ATARI cassette operating system is organized so that when you save data using the PRINT command, records are written to the cassette tape with three seconds of pure tone between them. By setting the auxiliary byte in the OPEN command to 128 the time delay between records is reduced practically to zero. This works fine for SAVE, but when you try to LOAD your data back into the computer, it can't take the data as fast as the tape is delivering it! An error status is generated and program execution stops.

The loop "FOR I = 1 TO 50 :NEXT I" in the save routine puts just enough delay between the data records that the error status is avoided, still giving you about a 30% time saving. Users of Tiny Text (see ANTIC V.1, No. 6) might also note that this technique will help them speed up text filing. I arrived at this delay factor by trial and error (Atari literature suggests that timing must be a function of program software). The 1 to 50 loop has been reliable for cassette work on my own system, but individual systems may require more delay (or possibly less). This method only seems to work with PRINT and INPUT commands, though, as I had no success when I tried it with PUT and GET. Trial and error seems the only way to find out.

If you wish to adapt Electro-Cardfile for disk operation, you may change lines 30, 7000, 7010, 7020, 8000, 8010, and 8020. The statement lines which you should substitute are found at the end of the program listing.

Electro-Cardfile has been a handy tool for my own use, and I hope that others will find it a useful addition to their software libraries.

Listing 1: CARDFILC.BAS Download

Listing 2: CARDFILD.BAS Download

VARIABLE LIST DEFINITIONS

A$ Keyboard input
CD$ Card data string
SA$ Card title string
TR$ Load/save transfer string
WS$ Card data input string
C$ Card data input string
A Position calculation variable
B Beginning point of string
C Card number
CH Menu choice variable
E Ending point of string
L Line number
M Number 15
N Number 10
O Number 30
P Number 1
S Counting variable
CAL1 Subroutine at line 100
CAL2 Subroutine at line 110
CAL3 Subroutine at line 120
CAL4 Subroutine at line 130
CHK Range check subroutines lines 150-159
FILL Subroutine at line 160
MENU Menu routine line 10000-10020
SCN Screen Clear Command