Classic Computer Magazine Archive START VOL. 1 NO. 3 / WINTER 1986



By Randy Gordon

Computerize your address book with this full-featured GEM program in Personal Pascal. Mailcall allows you to enter, search, edit, and otherwise manipulate a 175 record mouse-driven database. It also prints mailing labels and even dials your telephone. Find this program on your START disk in the folder labeled MAILCALL.STQ

This is the time of year when Andy Rooney fulminates about all those matchbook covers, envelope corners, and scribbles on the wall that collectively make up his personal address book. He could have them all under control with a computer, but he doesn't have room for one in his office. You, of course, are more up to date, and if you want to get your addresses and phone numbers organized on your ST, you'll find Mailcall waiting on the START disk to accept your information.

Mailcall is not just an address book, it's also a telephone dialer if you have a Hayes compatible modem. It will even use your "alternate long-distance carrier" if you don't have AT&T. The program is a GEM-based application that uses windows, mouse commands and keyboard input. It runs in medium or high resolution.

Each Mailcall database holds a maximum of 175 records, so you may not need more than one. Each record consists of the following fields: First Name, Last Name, Title (e.g., Mr and Mrs.), Address, City, State, Zip Code, Home Phone Number; Work Phone Number, and Extra (one-line scratch pad).

Whenever you run Mailcall, it will try to load two files: MAILCALL.DAT, which holds the database records, and MAILCALL.INF, which contains dialing and printing information. These will load automatically if they are in the same folder as MAILCALL.PRG. If MAILCALL.DAT isn't there, the program creates a new file of that name with zero records. This will be your situation the first time you run the program.

You need at least one valid record to do anything with Mailcall, and valid means some data for both the first and last names. To create a record, pull down the Main menu and select the Add item, the only active function for a zero-record database. Once you complete one record, all other functions become available. This is a good time to begin building the default database that will load when you run MAILCALL.PRG. Other options at this point are to load a database with a different filename (which you may have in the future), or create a new database with a different filename, as explained below.

The menu bar shows five headings. Desk contains any desk accessories you have put there, and any you choose will work with Mailcall. Main includes the functions to find records and enter data. File controls disk operations. Select prints or dials when a record is active in an open window. Option sets and saves parameters for printer and modem. All these functions use standard GEM conventions and procedures.


Search looks for a specific name either First Name, Last Name, or First and Last name, and disregards capitalization. If no match, the program shows the first record in the file. When it finds a match, it opens a fully active window to display all fields of the record. The title line shows the entire pathname. The up and down arrows in the window frame scroll backwards and forwards through the database, one record at a time. The grey areas on either side of the slider bar scroll ten records at a time.

Edit enables you to modify a record in an active window. When the Edit dialog box appears, just click the mouse on the field to be edited and use standard GEM editing keys. The [ESC] key totally clears any selected field. The up and down arrow keys and the [TAB] key move control between the different fields. The [RETURN] key is disabled during data entry. After editing, either save the changes by clicking on OK or cancel. If you make a change, the program will sort all the records and a small window will announce this activity.

Delete searches for a specific record, and if found, requests a protective confirmation; just select the appropriate box.

Add creates new records. It works much the same way as Edit, except you begin with a blank record and it cycles to a new entry each time you finish a record. A click on OK commits the new record to memory. It's handy to just leave the mouse pointer sitting on OK while you work. The program automatically capitalizes the initial letters of First Name, Last Name, Title, City and State (both letters).

Print Range is the way to print out multiple records either in report form (all data) or label form (name and address only). The program always sorts alphabetically by last name, and starts and ends printing wherever you specify. To print all the records beginning with a single letter, omit the ending range. You can stop printing at any time by pressing any key.

Quit exits from the program. If you made any changes, the program prompts you to save them.


You can load a database, save the current database, or start a new one. First priority goes to saving any database in memory that has been changed since it was loaded. After the program prompts you to save any changes, Load New File checks to see if the new file is a valid database, then loads it. Load uses the standard GEM item selector box and defaults to the currently active drive.

Save Changes saves the current file in memory to the same filename and pathname it came from, provided it is a valid database.

Select is only active when a specific record is in an open window. Its purpose is to print a single label or record, or to dial a phone number. Set the parameters for this output with the Option menus, either Print or Dial. Both use dialog boxes. Print controls the number of spaces to indent from the left margin, the spaces between successive labels, and whether to put the title before the first name (e.g., Dr John Brown). Click the mouse to make these selections-a check mark in the box indicates your choice. When all options are correct, save them and exit the box by clicking on OK.

The Dial option dialog sets up the modem default settings, enters codes to select a long distance carrier, and chooses the dialing method. The default code ATS7=11DT sets up dialing on a Hayes compatible modem with touch tone phone and gives you an 11-second period to pick up the receiver. If you don't, the modem hangs up. This ringing time is variable from 1 to 255 seconds.

ALDC means alternate long distance carrier," and refers to your SPRINT or MCI codes. Enter your local access number, followed by two commas, and then your security number Click on one of the three boxes-ALDC, AT&T, or LOCAL- to select the method of dialing. With ALDC, tbe modem dials the alternate local access number and code, then the number of the other party. For AT&T, it dials 1 (if specified), then the area code and number of the party. LOCAL ignores the first three digits of the phone number, so you must include the area code for local entries-preferably in the form 123-456-7890. For local numbers that require a leading 1, two solutions are offered: omit the area code, choose AT&T, and opt for adding 1 to that method; or choose LOCAL and enter the number as 123-1-456-7890. The two final options allow you to select Home or Work phone, and whether to dial 1 with AT&T.

Specify all of these parameters, then go to the record of the party you want to call, pull down Select, click on Dial, and pick up the phone.

The Save Options item saves your dialing and printing parameters to a file named MAILCALL.INF. This, you remember, is saved in the same folder as MAILCALL.PRG, so it loads automatically with the program.


I wrote the program in Personal Pascal from Optimized Systems Software. This language is very easy to use, especially when writing GEM-based programs. Personal Pascal has its own GEM library that is less complete than the one in the Atari Developer's Kit, but much easier to use. I have a 520 ST upgraded to 1 megabyte. I allocate 600K to a RAMdisk and copy all my Personal Pascal files and source code to the RAMdisk. This way I can compile and link a 70K source code in about 40 seconds. This takes some of the drudgery out of programming.

You will find the source code for Mailcall on your START disk in the MAILCALL.STQ folder. If you're interested in programming, the rest of this article describes how it works.

Each record in the database is 154 bytes long. The whole database is stored in memory in a Pascal data type called an array of records. Each record consists of a packed array of char for each field. Personal Pascal limits arrays to 32K, so the array only holds 175 records.

When you load a database, the number of bytes in the file is divided by 154 to get the number of records. This sets a variable record_number which controls the number of records shown and limits the sorting and save functions to active records only.

The source code is long but straightforward. First, it sets the RS-232 port to 300 baud, then tries to load the default files. The program then calls the main loop, event_loop which looks for message events and terminates when the "Quit" item is selected. event_loop calls another loop, do_menu, which constantly checks for menu selections when no window is open and then calls whichever function or procedure is required by a specific menu selection. Each menu function corresponds to a logically named function: search, edit, add, option_print, option_dial, option_save, p_dialog (print range), and my_window (about program dialog). The three items under the File menu heading are built right into the do_menu loop. All functions and procedures are returned to this loop when completed.

Only search uses all window functions. It starts by searching for the first and last name. When found, a variable i is given a number corresponding to the actual position within the array of the records. The window is opened and a procedure called print then prints the field titles to the window. Next a procedure called show prints the information within fields. print and show take into account whether medium or high resolution is in effect. The only difference between high and medium resolution is the vertical positioning. High resolution uses a 16 x 8 pixel font and medium resolution uses an 8 x 8 pixel font.

After the window is printed, the program enters another event_loop, which continues until the user clicks on the close box, sending a wm_closed message. This loop handles all active menu selections and all window changes, including GEM redraw messages. Whenever there are window changes, GEM sends the new information in an array of integers called msg of message_buffer type. When the program receives a message that requires action, it looks at msg to determine which action to take.

Several events trigger the wm__redraw message: whenever a window is topped (brought to the front), or made larger, or when new parts of a window are shown by moving or closing a window or closing a dialog or desk accessory. It is up to the programmer to redraw the window by calling first_rect. It returns x-position, y-position, width, and height values. If the values for the width and height do not equal zero, then redrawing is necessary. Next there is a call to rect__intersect. This will return the x,y,w,h values of an area that needs to be redrawn. All that has to be done is to use set_clip to confine drawing to this area and to redraw the screen with print and show. You must repeat this process using next_rect instead of first_rect until the width and height are 0.

When there are size or position changes, GEM sends a wm_sized or wm_moved message respectively. The new data which is used in set__wsize is returned in msg. set_wsize, if given a window handle and new x,y,w,h information, will place that window at the new position (xy) for the specified width and height (w,h). It may or may not generate a redraw message. Scroll arrows, grey areas, and the slider bar pass messages in a similar fashion. The wm__arrow message will show all scroll functions except the slider bar which is sent via the wm__vslid message. The program determines where to scroll from these messages, and calls print and show to redraw the screen with the proper record. GEM returns the position of the scroll bar in msg, but the programmer must manually move the bar into its new position. This is done with the wind_set procedure using wf_vslide as the second variable.

wm_topped is the message that GEM sends when the user wants to bring a window to the top and activate it. The procedure bring_to__front is called with the window handle as its parameter to accomplish this.

wm_fulled is sent when the full box is clicked on. The program compares the size of the window with its maximum size returned by wind_get using wf_fullxywh as the second variable. If they are the same (window is full), then wind_get is called with prevxywh as the second variable. This returns the window's previous size before being fulled. set__wsize can now be called with the values of the window's previous size. If they are not the same, (window is not full) then set__wsize is called with the results of wind_get, with wf__fullxywh as the second variable (maximum size).

Mailcall provides a quick and friendly means of bringing your address book into the computer age. If you find 175 records too constraining, try segmenting your addresses into a number of different databases by category. Also, I encourage enterprising Personal Pascal programmers to customize or expand the program. I find Mailcall extremely useful and I hope it fills a gap in your software library.