Logo Mailing List
Powerful mail-merge utility
Here's a useful, Convenient mailing-list application for the Logo programming language. Logo Mailing List works on all 8-bit Atari Computers of any memory size. It requires a disk drive, a printer and the Atari Logo language.
We find it easier to write a data management program such as a mailing list in Logo than in BASIC.
So much has been written about the turtle geometry features of the Logo programming language that we sometimes wonder if everyone has forgotten about Logo's LISP (LISt Processing) heritage. LISP, the keystone language of artificial intelligence programming, shares a number of features with its descendant that make Logo an ideal language for writing programs to manipulate data in the form of words and lists.
The two types of objects in Logo are words and lists. Logo provides several primitives to construct lists, such as FPUT and LPUT-and to take apart lists, such as FIRST, LAST, BUTFIRST and BUTLAST The primitives EMPTYP and EQUALP are useful for controlling lists.
FIRST is used to obtain the first object in a list or word. LAST gets the last object in a list. BUTFIRST (BF) allows access to the internal objects in a list, returning all but the first object. To get at the inside parts of a list, BFs can be piled up, one after another, to strip several objects from the list. BUTLAST (BL) works the same as BUTFIRST, except from the other end of the list.
FPUT, for "first put," takes two inputs. The first is an object (word or list), and the second is a list. For example:
MAKE "NAME "TERRAPIN,
MAKE "PHRASE [THE BIG GREEN TURTLE]
MAKE "NEW FPUT :TERRAPIN :PHRASE
prints the list called "NEW:
TERRAPIN, THE BIG GREEN TURTLE
Carefully type in Listing 1, MAIL.LGO. (TYPO II does not work with Logo.) SAVE a copy to disk. To start the program, type ADDRESS. Antic Disk owners should copy the 8-bit program, MAIL.LGO, to another disk before using it.
We begin building the mailing list program by deciding what we want to do. The choices are:
Create a new mailing list
Add to a mailing list
Update an entry
Print out entire mailing list
Print out a selected name
Outlining the tasks helps identify the types of procedures we will need. Creating a mailing list means we must take a series of inputs, each consisting of a name, street address and city/state/ZIP code, which are saved as a datafile. Consequently, we'll need procedures which accept inputs and save the file constructed from the inputs.
To add to an existing file, we need one procedure to read in a datafile and another to tack new inputs onto the end of that file. Updating an entry implies the need for a procedure that can search for a given entry, as does the desire to print out a selected name.
Identifying the procedures still leaves unanswered the important question: how shall we organize the datafile? The answer is determined by the presence of Logo primitives that manipulate lists. The clear choice is to make the entire datafile a list that's built up from sublists. Each record in the datafile will consist of three lists: one holding the first and last name, one with the street address and one with the city, state and ZIP code.
Since Logo is a procedural language, it readily lends itself to the technique of breaking a large programming task into smaller pieces. We can impose additional structure into a Logo program by placing procedures into functional groups. We set up the following groups.
The Setup Group:
The Utility Group:
The Printout Group:
ADDRESS begins the program by loading the procedures. Pressing the C key produces a menu of options. The procedure CHOOSE, which is called by MENU, reads the keyboard, examines the response, choosing a correct sequence of procedures, and handles an incorrect input by displaying an error message followed by a return to the menu.
Program control flows in Logo when one procedure calls another procedure which calls a third, which calls a fourth and so on. When the last procedure in the chain is finished, control reverts to the previous procedure until it is finished, and then to the one before it and so on-until control reverts to the first procedure in the sequence.
Thus when the user selects item 2 on the menu, CHOOSE first sets up an empty list called "data," and then calls the procedure INPUT. Each pass through INPUT builds up a record composed of the sublists NAMELIST, STLIST and CITYLIST, which are recorded as the user's response to a prompt on the screen. After the user has a chance to make corrections, the lists are added to the data list by these three lines:
MAKE "DATA LPUT :NAMELIST :DATA
MAKE "DATA LPUT :STLIST :DATA
MAKE "DATA LPUT :CITYLIST :DATA
Then the procedure INPUT calls itself, thus looping around for additional inputs. The list "data" is built up as a sequence of records:
[[NAME] [STREET ADDR] [CITY STATE ZIP]]
[[NAME] [STREET ADDR] [CITY STATE ZIP]]
INPUT stops when the user enters END after the "enter name" prompt. Typing END sends the program to the procedure DATASAVE, which first puts an asterisk (*) at the end of the data list to serve as an end-of-file marker. DATASAVE then opens the disk with a file called MAILIST and prints the List DATA.
After a mailing list is created, it is occasionally necessary to update a record. Or, more often, one will want to print out a single record onto a mailing label. The list-handling primitives in Logo make it easy to write procedures that locate a specific record and then carry out subsequent actions. Of the two jobs, updating a mailing list is the more complex.
Updating a record begins with the line in CHOOSE that reads:
IF :CHOICE = "3 [CT UPDATE MENU]
This line clears the screen, calls the procedure UPDATE and tells the computer to go back to the menu when the updating sequence is completed.
UPDATE begins by calling GET-MALL, a utility procedure which opens the disk and reads in the data list assigning it a label, "DATA. After GETMAIL executes, control reverts to UPDATE. The next line:
MAKE "NEWDATA BL :DATA
removes the EOF marker and renames the data list, freeing the label "DATA for later procedures. Finally, UPDATE asks for the first and last names of the record to be changed and calls FIND, the searching procedure, which locates the record with the name-matching TAG and starts building up the corrected datafile.
If the first name in the datafile does not match the TAG, then the three lines beginning MAKE "DATA LPUT will assign this record to the list "DATA. That record is then stripped from "NEWDATA by three BLs. Then FIND tests to see if "NEWDATA is empty, in which case the whole file has been searched and the name given was not found, and an error message "No matching name located" is displayed. After a short wait, control goes back to the menu via CHOOSE. If the EMPTY condition is not met, FIND is called again, cycling through the data file, stripping records from "NEWDATA and putting them onto "DATA.
Once the proper record is found, FIND calls CORRECT, a procedure that prints the original entry and asks for new inputs. Once these have been given, this record is put in place of the old one in the file "NEWDATA. Now we have two data lists: DATA, consisting of all records up to the revised one, and NEWDATA, holding the updated record and all that follows.
The task of CREATELIST to merge these into the single file called "DATA. CREATELIST's operates similarly to the searching procedure in FIND. Once the "NEWDATA list has been completely merged into DATA, the updated file is saved with DATASAVE. Control is then transferred back to menu through the sequence of procedures starting with CHOOSE.
The procedures that carry out the printing tasks are self-explanatory. They manipulate lists in the same way as the UPDATE and CREATELIST procedures.
Marian Lorenz and Allan Moose are Long Island educators. They wrote Math Art, a sine wave image-making program in Antic, June 1986.
IF YOU'D ENJOY SEEING MORE ARTICLES LIKE THIS ONE, CIRCLE 208 ON THE READER SERVICE CARD.