Classic Computer Magazine Archive ANTIC VOL. 5, NO. 10 / FEBRUARY 1987

By Patrick Bass, Antic ST Program Editor

Electric Charlie

Pop-up window explains error messages

Electric Charlie! is more than just a demonstration of how to program a memory-resident pop-up window for Atari 8-bit computers. It automatically displays useful explanations of any error number message you might encounter while writing your own programs. This BASIC program works on all 8-bit Atari computers of any memory size, with disk drive.

Atari 8-bit BASIC is a good, solid language that packs surprising power into 8K and has served programmers admirably for almost seven years now.

However, one of the things I miss when using Atari 8-bit BASIC is detailed error messages. To conserve memory space, whenever an error happens inside Atari BASIC, the language spits out that familiar "ERROR xx AT LINE xxx" message-and "ERROR xx" is merely the number of the error that occurred. You then must look up--probably in a reference book--the real meaning of the error number.

Here at Antic we have it easy. Technical Editor Charles Jackson knows the error codes by heart. Four or five times a day some plaintive voice comes wafting across the office, asking, "Charlie, what's a 144?" or, "Charlie, what's a 128?" Charlie rattles off the error and everybody's happy.

HEARTBREAK HOTEL

Recently, though, Charlie got sick and had to stay home for a few days. Panic set in right after the first "Charlie" call went out. Work ground to a halt as we went looking for lists of error messages.

In desperation, we even phoned our favorite computer company. A secretary listened to our problem and asked us to hold. Then somebody came on the line and said that whenever anyone there got an error message, they called Charlie Jackson at Antic. But he didn't seem to be in that day.

ELECTRIC CHARLIE

Thus was born the need for Electric Charlie, a utility for Atari 8-bit BASIC programmers which pops up a window on the screen showing the last known error number, the line where the error occurred-and a short description of the type of error that occurred.

When Electric Charlie! is installed, you just program along in Atari BASIC. When BASIC stops at an error, simultaneously press the three keys--[SHIFT] [CONTROL] [ESCAPE]. Electric Charlie! pops up on the screen to tell you which error actually happened. The next key you press will close the Electric Charlie! window.

Electric Charlie! lives on disk as an AUTORUN.SYS file. When you boot your Atari 8-bit computer with this disk, Electric Charlie! will automatically install itself in low memory, above DOS and helow the start of BASIC's memory. It will then sit quietly and look at each keystroke. When Electric Charlie! sees that you have simultaneously pressed [SHIFT] [CONTROL] [ESCAPE], its window pops up and displays the last known error code. Any keystroke that follows will close Electric Charlie! and restore the full screen.

TYPING IT IN

Type in BASIC Listing 1, CHARLIE.BAS, check it with TYPO II and SAVE a copy to disk before you RUN it. You do not need to type in assembly language Listings 2 and 3 in order to RUN the program.

When you RUN Listing 1, it will create a disk file called CHARLIE.EXE. Antic Disk owners: You will find CHARLIE.EXE on this month's disk.

Transfer CHARLIE.EXE to another disk and rename it AUTORUN.SYS. Make sure the new disk has been formatted using DOS 2.0 or DOS 2.5 and contains the DOS.SYS file. Now just turn your computer off, then back on. Electric Charlie! will load and run automatically.

The program first presents a short message across the top of your video screen, reminding you that Electric Charlie! has been installed. At this point, just start programming in Atari BASIC. Electric Charlie! is ready to help you at a moment's notice.

ASSEMBLY TAKE-APART

Listing 2, CHARLIE.M65, and Listing 3, CHAA.M65, are Electric Charlie! written in 6502 assembly language as implemented in MAC/65 from Optimized Systems Software. The listings are teaching examples for assembly language programmers. Listing 2 is a master file, used as a base to assemble additional code fragments. In this case, we have only one such fragment, Listing 3.

The opening lines of Listing 2 contain definitions for 5 macros. These are sections of code which will be called later in the listing. With macros, entire blocks of code may be defined once, then used throughout the code by simply stating their names.

The program begins at line 1090, and starts by jumping to a later section of code which will install Electric Charlie! into BASIC.

Below that, the ACCESSORY subroutine checks each one of your keystrokes to see if it is [SHIFT] [CONTROL] [ESCAPE]. If it is, we open the window. If it isn't, the window is closed and the character is passed along to BASIC. If the window is open, any subsequent keystroke will close it.

The calculated addresses for the window and the text inside the window are found between lines 1840 and 1860. Below that, the SETUP subroutine installs Electric Charlie! into BASIC.

Lines 2330 through 2520 contain the character map for the window. Feel free to change the size of the window, as WIND.W (window_width) and WIND.H (window_height) are calculated automatically when you assemble the program.

OPEN WINDOW

Now we get to the subroutine which opens the window. But before opening the window, we determine what information it will cover up--and we save that information to another part of memory. It never gets any harder than that. The following routine, CLOSE.WINDOW, reverses this procedure by replacing the saved screen memory. This erases the window.

Next, starting at line 3200, the ADJUST subroutine accepts standard ASCII characters and converts them into Atari's internal POKE codes. We don't PRINT in Electric Charlie!--we POKE characters to the screen.

WORKING WINDOWS

The subroutine WORK.WIND0W calculates and places the information inside the window. First it prints out the error number, then the line the error occurred on, and finally the explanation of the error.

The last three sections of code in Electric Charlie! are where we keep tables of information needed by the program. First, we find the table called ERROR.TABLE, where we keep a list of every known error. Next comes ERROR.JUMP, containing the addresses of the corresponding error messages. Finally, we find the table of descriptive error messages themselves, again stored in the same order as the two previous tables.

Electric Charlie! sure does help. It's not perfect, because BASIC can generate errors faster than Charlie! can keep up. But all in all, it's very useful for those of us who don't know the Atari error messages by heart--and who don't have the real Charles Jackson working at a desk within shouting distance.

Listing1:CHARLIE.EXE Download

Listing2:CHARLIE.M65 Download / View

Listing3:CHAA.M65 Download / View