Classic Computer Magazine Archive COMPUTE! ISSUE 87 / AUGUST 1987 / PAGE 93

XpressCard Filing System

For The Commodore 64

Robert Bixby

Though it's small in size—only 2K—this Commodore 64 filing program packs plenty of wallop. "XpressCard" lets you store an amazing 60K of information in memory at a single time. Written in machine language, this compact program lets you enter and retrieve data, search and sort records, load and save entire files, and perform other basic filing functions. A disk drive is required.

How much software do you have that takes full advantage of the Commodore 64's hidden memory? Concealed under the computer's BASIC and Kernal ROM (Read Only Memory) chips are more than 16, 000 bytes of memory which ordinary programs rarely tap. "XpressCard" is a fast, convenient filing system that takes full advantage of those underused areas, yet the program itself is only 2K in length. It's the electronic equivalent of a conventional card file, providing over 60K of quick-access storage. With easy-to-remember function key commands, you can load and save files, search and alphabetize records, insert and delete records from a file, and even make hardcopy printouts.

XpressCard is written in machine language, so you'll need to enter it with the "MLX" machine language entry program printed elsewhere in this issue. When you run MLX, you'll be asked for the starting address and ending address of the data you'll be entering. Here are the values to use for XpressCard:

Starting address : 0801
Ending address : 0FF8

Follow the MLX instructions carefully and be sure to save a copy of the XpressCard data before you quit typing. Once you have saved a copy, the program can be handled just as if it were BASIC. If you saved the program with the filename XPRESSCARD, for instance, you can start it by entering the command LOAD"XPRESSCARD" followed by RUN. To make new copies, simply load the program into memory, change disks, and save it as you would a BASIC program.

Moving Around The Card File

Once you have entered XpressCard, load and run the program as if it were an ordinary BASIC program. When you begin, the program presents the equivalent of a blank file card. Since you haven't loaded anything into memory or entered any data, you begin with the first card, which is numbered 001. The highest card in the file is numbered 237.

The upper portion of the screen (above the solid line on the display) is where you enter data for the current card and review its contents. A single card can hold up to 255 characters—about six-and-a-half screen lines. Below the solid line you will see the contents of the next higher card (if that card happens to contain data).

Four of the 64's function keys are used to move around in the card file. The f7 key actually has two functions: It both saves the current data in memory and moves you to the next card in the file. This feature saves time when you are entering a lot of data in numerical order. The f8 key (press SHIFT-f7) moves you back one card (but it does not save the current card). If you are already at card 001 and you press f8, you move to card 237. If you're already at card 237 and you press f7, XpressCard both saves card 237 and moves you forward to card 001. The f6 key (SHIFT-f5) returns you instantly to card 001 no matter which card you're currently working on.

Entering And Editing Data

The flashing underline cursor in the top screen area indicates your position within the current card. You can enter text in this editing window as if you were writing with a word processor. You can use the cursor keys to move around within the editing area. If you type beyond the capacity of one card, or if you move the cursor beyond the last character in the card, XpressCard automatically saves the contents of the current card and moves you forward to the next card. Otherwise, you must press f7 to save the current card and move ahead.

The RETURN key has no effect in the editing window. To begin a new line, use the cursor keys or simply hold down the space bar until the cursor wraps around to the beginning of the next screen line. To erase text from the card, press the INST/DEL key. It's also possible to insert text with SHIFT-INST/DEL. The bottom 256 spaces of the screen represent a buffer, or temporary storage area. If you insert blank spaces in the current card so that characters scroll past the end of the card, the data automatically goes into the buffer rather than onto the next card. The buffer contents can be recovered with the retrieve function (see below).

You can clear the editing window at any time by pressing SHIFT-CLR/HOME.

Special Functions

The f5 key activates a special mode that provides a number of additional editing features. Whenever you press f5, XpressCard changes the border color and waits for you to press a second key. Most of the f5-mode functions return to the editing window after performing their operations. For others, you must press RETURN to return to editing the current card. You can also press RETURN to cancel the f5 mode.

In the special f5 mode, XpressCard recognizes the following keys:

CRSR up/down. Allows moving by large increments. Pressing the CRSR up/down key alone in f5 mode moves you immediately to card 049, while pressing SHIFT in conjunction with CRSR up/down moves you to card 097. Press the Commodore key along with CRSR up/down to move to card 145, or CTRL with CRSR up/down to move to card 193.

A. Alphabetizes the cards in memory, beginning with card 001 and ending with the card currently shown on the screen. Remember to move to the last card you want alphabetized before giving this command. If you have filled all 237 cards and want to alphabetize all of them, move to card 237 before selecting this option.

The cards are sorted alphabetically according to the first character on each card. Uppercase letters are considered equivalent to lowercase letters. To avoid sorting anomalies, letters are alphabetized before numbers and spaces. Nonalphanumeric characters such as graphics symbols have the lowest priority of all.

Note that this function doesn't do a complete sort; only an ordering based on the first character position. For example, after alphabetizing all cards with the letter A in the first position will appear before any card with B in the first position, but within the group beginning with A the cards will appear in the order in which they were found in the file, and not in true alphabetical order.

C. Clears the buffer at the bottom of the screen.

D. Deletes the current card (the one shown in the editing window at the top of the screen), storing its contents in the buffer. All cards above the current card are copied down into the next lower card. Thus, after a deletion, the current card will contain the contents that were in the next higher card.

Delete takes longer for low cards than for high ones. In order to perform a deletion, the program must move around the contents of all higher cards. The lower the card, the more cards that must be moved.

F. Performs a position-sensitive string search. Before activating this feature, move to an empty card so that you'll have a clean space to enter the search string. Type the string you want to search for in exactly the same location within the blank card where you expect it to appear in existing cards. Once that's done, press SHIFT-RETURN to copy the search string into the buffer at the bottom of the screen. Next, move to the card where you want the search to begin. (To search all cards, press f6 to move to card 001.) Finally, press f5 followed by F.

XpressCard begins at the card currently on the screen and searches forward for a card which matches the search pattern. If a match is found, that card will become the current card in the editing window. You can enter f5 mode and press F again to search for the next matching card in the file. If no matches are found, you return to card 001.

Spaces in the search string are treated as wildcard symbols; a space can match any character. Thus, the search string S N (S followed a space followed by N) matches the strings SANE, SUN, SAND, and any other card containing the characters S and N in the same relative position within the card.

SHIFT-F. Performs a string search that is not position-sensitive. That is, it finds strings that match the search string, no matter where those strings might appear in their respective cards. The process for setting up the search string is the same as for the F option, but no wildcards (spaces) are permitted in the search string, and the search string must begin in the upper left corner of the buffer.

For this search, XpressCard treats the space character as a delimiter rather than as a wildcard. The first space character in the search pattern marks the end of the pattern. Thus, if you type FOR RENT as the search string, the program might find spurious matches such as INFORMATION, AFFORDABLE, BALFOR, or FORTITUDE, since all of those words contain the characters FOR. In this case, it might be more appropriate to search for RENT.

I. Copies the contents of each card beginning with the current card and moving to the next higher card. If you need to make many copies of a card—perhaps as a template or pattern—insertion provides an easy way to do it.

Insert takes longer for lower-numbered cards than for higher ones. In order to perform an insertion, the program must move the contents of all higher cards. The lower the card, the more cards that have to be moved.

Be careful about inserting when the card file is nearly full. Insertion causes all cards above the insertion point to move upward in memory. However, the information in card 237 has nowhere to go during an insertion. Thus, whatever card 237 contained is simply lost during each insertion.

L. Loads a card file into memory for review, printing, or some other operation. Remember to put an A before the filename for files that contain fewer than 192 cards, and a B at the beginning of the name for larger files.

P. Prints the current card on a printer. Be sure the printer is connected and turned on before you select this option. Note that XpressCard prints ordinary alphanumeric characters (letters, numerals, and punctuation) but ignores graphics symbols, printing them as blank spaces.

The default printing mode for XpressCard is to print each file card exactly as it appears on the screen, with a width of 40 columns and height of six lines. If needed, however, you can alter the printer formatting by making three POKEs in direct mode before you run the program. To do this, load XpressCard as usual, but do not run it. Enter this line and press RETURN:

POKE 702, 47 

This POKE prevents XpressCard from using the default printer settings. Next, determine how many columns wide the printout should be and how many characters you want to print from each card. POKE those values into locations 703 and 704, respectively. For instance, you might use these settings to print an address label containing three lines of text, enough for a name, address, and city, state, and zip code:

POKE 703, 40
POKE 704, 120

The first POKE retains the default width of 40 columns, and the second tells XpressCard to print the first 120 characters from each card.

R. Retrieves the contents of the buffer, moving that data into the current card at the top of the screen. The previous contents of the card will be lost; the data in the buffer remains unchanged. This feature also allows you to make multiple copies of a card.

S. Saves the file, beginning at card 001 and including the card currently on the screen. Data in cards beyond the current one is ignored when you save, so be sure to move to the last active card in your file before giving this command. This feature allows you to save a file that's smaller than the maximum 237-card size, which takes up about 242 disk blocks.

You'll be asked for a filename for your data file. When specifying a filename for the save, you must use a name no more than 15 characters in length. If the file contains fewer than 192 cards, XpressCard automatically adds the character A to the beginning of the filename you specified. When reloading the file, be sure to add A to the beginning of the name you used.

Very large files (more than 192 cards) are automatically broken into two disk files: XpressCard automatically adds A to the beginning of the first filename and B to the beginning of the second file. When reloading such a file, load the B portion first. XpressCard will then automatically load the A portion after the other part is in memory.

4. Displays a listing of the disk directory (think of the dollar sign in the shifted position of this key). To freeze the listing, hold down the space bar. When you release the space bar, the listing continues. Press RETURN after the listing is complete to return to the editing window.

RUN/STOP. Exits to BASIC. It is wise to save your data file before you choose this option. However, after exiting you can type RUN and reenter XpressCard with your data intact as long as you don't perform any other BASIC operations in the meantime.

Miscellaneous Functions

The f4 and f1 offer two additional features. The f4 key erases the data in every card from the current card to card 237. Since this drastic action is irreversible, XpressCard requires that you confirm it by pressing Y before it proceeds.

The f1 key accesses two additional pages (256-byte chunks) of buffer memory. This allows you to save the current contents of the buffer before you erase all files, for instance. The contents of the three buffer storage areas are rotated into the active buffer in a cyclical pattern.