Classic Computer Magazine Archive ANTIC VOL. 6, NO. 9 / JANUARY 1988

Featured Application


All-around database power with ease

TopShelf is an outstanding all-around database program that offers many powerful features and is easy to use. You can load TopShelf data files into your word processor and print good-looking reports. The BASIC program works on 8-bit Atari computers with at least 48K memory and a disk drive.

TopShelf is an easy-to-use, menu-operated database program with many high-powered features. TopShelf sorts your data any way you like, saves your files on disk and retrieves them-even does arithmetic calculations. You can load TopShelf files into your word processor and format them for classy printouts, or you can print unformatted TopShelf reports direct from the program.

Databases are among the most popular types of software. An airline timetable is a good model for how a database is set up. Everything you need to know about the arriving and departing flights is neatly arranged in a table. Along the top of the table, the up/down columns are labeled "Flight Number," "Departure Time," "Arrival Time" and so on.

Each sideways row in the table is the entire record of a specific flight. Each up/down column is a field (category) of information used in all the flight records.

Most airline schedules are arranged alphabetically by the destination of the flight. For example, flights to Aspen are listed before flights to Washington. We can say that this database's records are sorted on the destination field.

Electronic databases are programs which can search, arrange and report information on any field. An electronic database of different airline schedules would let you search through every airline's flights to a specific city, sort them according to airfare, and find you the cheapest flight.


Now you can easily create your own database files with TopShelf. Type in Listing 1, TOPSHELF.BAS, check it with TYPO II and SAVE a copy before you RUN it.

If you have trouble typing the special characters in lines 5040-5060 and 5071, don't type them in. Listing 2 will create them for you. Type Listing 2, check it with TYPO II and SAVE a copy to disk. When you RUN Listing 2, it creates these hard-to-type lines and stores them in a disk file called D:LINES.LST.

To merge the two programs, LOAD "D:TOPSHELEBAS" then ENTER "D:LINES.LST". Finally, remember to SAVE the completed program before you RUN it.


When you RUN TopShelf, it displays a white screen with a gray menu bar at the top. This is the first of two menu screens. Press [M] to see the second screen, press the [ESC] key to return to the first.

First, get a sheet of paper and write a brief outline for your database. Draw four columns on your paper and label them FILENAME, DESC, SIZE and DISK #. These represent the four fields we'll use.

RUN the TopShelf program. When the first menu bar appears, type [M] to access the second menu. Now press [C] to [C]reate a new data file.

The words NO, TITLE, LENGTH, TYPE(C/N/F/S) and DEC should now be displayed at the top of the screen. These will help you design each field in the database.

The TITLE of the first field on our paper database outline is FILENAME. Type FILENAME and press [RETURN]. The cursor will appear beneath the word LENGTH. Since Atari filenames cannot be longer than twelve characters, type a 12 in this column and then press [RETURN].

The cursor will appear beneath the letters TYPE(C/N/F/S). This lets you define the type of information to be kept in the field. [C] gives you [C]haracter text data and [N] stands for [N]umeric data. (Later in this article we'll explain the other choices, [F] for [F]unction and [S] for [S]tatement.)

Since filenames are strings of characters, type [C] and press [RETURN]. Since the DECimal column is only used with numeric data, the cursor returns to the TITLE column. The FILENAME field is complete.

The second field on our paper database is called DESC. It will be a one-word DESCription of the file you are indexing-BASIC, text, picture, etc. The TITLE for this field will be DESC. We'll arbitrarily assign it a LENGTH value of 8. Since DESC is a character field, enter a [C] in the TYPE category.

The third field on our paper, SIZE, is the size of the file in sectors. Type the word SIZE in the TITLE column, and press [RETURN]. Next, fill in the value for the LENGTH column. Since you're not likely to come across a file larger than 999 sectors, you'll only need three places to hold your SIZE values. Type 3 and press [RETURN].

Since the SIZE field will only hold numbers, it is a numeric field. Type an [N] in the TYPE column and press [RETURN]. This time, the cursor moves to the DECimal column.

DEC lets you specify the number of decimal places you'll use in arithmetic calculations. For example, if you're dealing with dollars and cents you'd type 2. This would actually add three spaces to your SIZE value-two number spaces plus a third for the decimal point. Since our sector counts will always be integers, type [0] in the DEC column and press [RETURN].

Our final field will hold the disk identification number, titled DISK #. If you number your disks the same way as you number your checks, you'd have fewer than 10,000 disks and you'd type 4 for LENGTH. Since this is a numeric field, type [N] in the TYPE column, then type the number of decimal places in the DEC column.

We've created our four fields. At this point, the cursor is on line 5 of the TITLE column. Press [RETURN] to go back to the main menu.


Adding data to the database is as easy as completing a form. From the main menu, type [A] to add data. Field by field, the program will prompt you to type the data. Using the above example, the program would prompt you for a FILENAME, the DESC (file description), the SIZE and the DISK #. Remember to SAVE your data file regularly!

You can also use the [C]reate option to change the fields of an existing database. For example, you could use this command to change the name of your SIZE field to COUNT or AMT But be cautious: If you press the [SPACEBAR] twice while in the TITLE column, you will erase the entire field and every field below it!

Before your database grows too large, you should also practice using the functions described below.

   VIEW lets you look through data which has been sorted on the field of your choice. When data is on display, another menu appears. Pressing the [SPACEBAR] shows either the next matching data item or the END OF DATA statement and the Main Menu. Previous data remains on the screen. To clear the screen, press the [ESC] key.

   BROWSE shows your records one at a time-from either the beginning, middle or end of a file.

   ADD lets you put a new data item into your file.

   SAVE will store your file on disk. But don't type the "D: before the filename; the program does this automatically.

   LOAD retrieves data files that have been previously saved to disk.

   MORE displays the second part of the main menu.

   To EXIT the program, you could press the [RESET] key. But this way is so much more dignified.


The second menu screen contains the following options:

   SORT, which sorts your data on whichever field you select.

   FIND searches the database for matching data. For an exact match, you must use quotes at the beginning and end of the search string. When the data has been found, another menu appears asking if you want to DISPLAY, PRINT or SAVE it.

   The PRINT selection transfers unformatted data to virtually any printer. The SAVE choice lets you store the data on disk in either of two ways. You can save it as a standard ASCII text file-for use with most word processors. Or you can save it as data and create a new data file.

   You can display the DIRECTORY of the disk in any drive you select.

   On several menu selections you'll see + :-:RETURN ENTERS. This means that if you press [+], the next field is displayed on the top of the screen and the bar moves down one. Pressing [-] moves the bar up one field. Pressing [RETURN] indicates that this is the field you want to use.

   When you VIEW or BROWSE the file, you'll see a new menu whenever data appears. This is for corrections. You advance one at a time with + or-and using the [SPACEBAR] to continue within the field you selected. Pressing [ESC] from any blinking cursor clears the screen and returns you to the main menu. Pressing [CONTROL] [P] transfers the data on the screen to the printer.


Sometimes the value of one field is based on the values of previous fields. A database which computes grade averages is a good example of this. In this case, the final grade is determined by a function (formula) which uses grade values from previous fields.

The [F] key lets you do simple mathematical [F]unctions on one or more fields. This only works on numbers within fields. And the data must have been entered before the math function was selected. You program the function by typing the field number and the operation to be performed. For example, 1+2*3-4 means, "Take field 1, add it to field 2, multiply that by field 3 and subtract field 4 from the total." You must start with a field number and end with a field number. To program your function, you've got 20 bytes for each field.

Also, TopShelf [F]unctions cannot use any constants- such as a 7% sales tax. But there is a way to get around this limitation. If you need to use a constant for your calculations, select the field type as [S]tatement. This lets you to enter anything you want in that field, be it a number or a comment. Your entry will be displayed automatically whenever you add data to the file. If it's a number, you can have a function calculate it just like any other data. Otherwise, the [S]tatement will be treated as a comment.

Lester Block lives in Massapequa, NY and this is his first publication in Antic. He has been programming for three years on his Atari 800.

Listing 1  TOPSHELF.BAS Download

Listing 2  LINES.BAS(not needed)