Classic Computer Magazine Archive ANTIC VOL. 6, NO. 2 / JUNE 1987

ALICE-THE PERSONAL PASCAL

First interpreted ST Pascal

Reviewed by David Plotkin

Alice-The Personal Pascal (or just Alice) is the first interpreted Pascal to become available for the Atari ST. It features a syntax-directed editor, compatibility with Borland's Turbo Pascal, extensive help facilities and good GEM support.

THE ALICE EDITOR
The first unusual thing about Alice is the text editor. A "syntax-directed" text editor is, basically, an intelligent helper in your programming efforts. It detects what you're entering from the keyboard and determines if what you've punched in is in the correct syntax. It does this by laying out templates for you to fill in. For example, if you enter the keyword FOR, Alice will respond with:

FOR variable : = start to finish do

begin statement

end;

   By using a variety of keys (primarily the Tab key), you then advance through the underlined words, filling in the necessary information. Alice will not let you change words which must remain untouched, such as "do" or "begin". Further, as you begin to fill in a general line like "statement" Alice will help you with the syntax, laying out a template for PROCEDURE calls, WRITELN, or anything else you decide to put there. You can, of course, add additional "statements", or change your mind, delete the information you have typed previously and start again. Alice will even help you within statements. For example, if you type WRITELN, Alice will respond with: writeln( Value). After you fill in "value", you can type a comma or arithmetic operator (+ ,-,DIV, etc.) and Alice will continue with (for example): writeln(xvar DIV Value).

The amount of help Alice's syntax-directed editor will give you is impressive. Type in a Procedure call, and Alice will lay out the template, even including the variables based on your earlier Procedure definition. Use a variable you have not yet declared or call a Procedure you have not yet defined, and Alice will warn you. Then, all you need to do is type in "var" and the editor will return you to the variable declaration section of the program to add a declaration. It even in-dents your listing automatically, making it easier to read. You can hide whole blocks of code (leaving only a comment behind) so that your program listings don't get too busy. This is especially useful when including long libraries (provided on the disk) in your program.

You have no less than three different ways to enter commands. The first, and simplest, is to use the drop-down menus. Alice is totally GEM-driven. Once you get to know the program better, you can use the function keys so you don't have to go looking for the mouse. Finally, you can invoke a "command line," the most efficient way to use commands requiring additional data (such as the name of the file to load). You can put the additional data on the command line, which prevents you from having to deal with choices in dialog and alert boxes before the command can be executed. The commands range from adding and deleting statements and blocks of code to working with more than one file at a time, getting help, setting marks (to find your way to a particular portion of code), editing and debugging.

The editing commands also help prevent you from making syntax errors. For example, to delete a block of code, you must highlight it first. It is impossible to highlight anything other than a complete block. For example, if you highlight the name of a Procedure, the entire Procedure will be highlighted. Obviously, the Procedure makes no sense without a name, so the whole thing will be deleted if you proceed. On the other hand, it is quite possible to delete just one value from a WRITELN statment, since this is legal.

My favorite and most-used command is "symbol completion." This nifty little programmer's helper will fill in missing data for you. For example, if you just type PRO on a new line and call for symbol completion, the complete template for a PROCEDURE will be laid Out. If you ask for symbol completion where a variable is required, the name of the variable will be filled in if enough letters have been typed to uniquely identify the variable. Otherwise, a list of possible variable names will be presented that fit what you have typed in so far, and with the mouse, you can just choose the one you want. This is great if you can't remember the exact spelling of a variable or are too lazy to type out the whole variable name. "Symbol completion" is available anywhere, including for TYPE names.

Of most interest to beginners is Alice's "Dynamic Help Facility." There's so much information available here I doubt you would need to go to a Pascal manual ever again. There are basically three parts to the help facility. First is general help. This is a series of screens with general information about Alice. Most of this can be found in the manual, and I rarely used it.

The second part is more specific


Alice-
The Personal Pascal
is an excellent
implementation of
(in my opinion) the best
structured language
ever developed.
It is ideally
suited to beginners.


help information. You can ask for an explanation of your last error (Alice remembers most of what you have done by using a "history list"), a longer explanation of a current error message or your last error message, or information about Pascal. This last is quite useful, and the help presented is context-sensitive, depending on where the cursor is. If the cursor is sitting on a variable name in a multiplication statement in a WRITELN within a FOR loop which is part of a Procedure call, the help menu will give the following choices on what help you want: Symbol, multiplication, Writeln command, FOR loop, and Procedure call. Click on "Procedure call" and the help screen that comes up will tell you all about Procedures. Because the menus of your available choices for help are constantly changing, depending on where you are in the program, this is called the "Dynamic Help Facility".

The last part of the help facility is "What can I type." This presents you with all the legal choices to enter at the current cursor location. For example, if you ask for this help when the cursor is on Statement, the list will include such words as FOR, IF, WHILE, and others. You may choose one by clicking on it with the mouse.

The syntax-directed editor will not be for everyone. The experienced Pascal programmer may find the limitations of the editor chafing. You can't simply sit down and enter text the way you would with, say, OSS Personal Pascal. But for the majority of us who are just learning Pascal or are not completely comfortable with it, this editor is a big help.

RUNNING YOUR PROGRAM
Once you've entered your program, the next big step is to try and run/debug it. Alice makes this much simpler than a normal compiled Pascal. With a compiled Pascal, you must compile and link the program, run it, and attempt to figure what might've gone wrong. Not only is this a time-consuming process, but you can't stop and ask for the current value of different variables the way you would with BASIC. Also, the problem is caused frequently by syntax. Alice will change all that. The syntax problem is largely taken care of by the editor.

Beyond that, though, Alice is an interpreter, just like most of the BASICs you're used to. Thus, you can run the program immediately (no compile or link), break into it in the middle or set breakpoints in the code for the program to stop executing. You can even single-step through your program, executing one statement at a time and watching for problems. At any time where execution has been halted, you can input what are called "Immediate Blocks." These blocks are ignored during a normal run, but by positioning the cursor on a line within an Immediate Block, you can execute just that one line while the program is paused. Thus, if you are not getting the value of X you thought you would, just set up an immediate block with the command WRITELN(X). When executed, this line will print out the value of X in the output window!

You can use just about any program lines in the immediate block that you can in the main program, including Procedures, loops, decisions, etc. The only limitation is that since variables in the program are undefined except while the program is running you must ask for this information by forcing the program to stop executing in the middle. You can't ask for the values of variables after the program is finished, for they are once again undefined. You can even use the Immediate block to change the value of a variable in the middle of a run.

The single-step way of running your program is very useful for debugging. Each time you single-step, one line of your program is executed. Of course, this can be quite time-consuming, especially if you have a loop which sets 1000 elements of an array to zero. To get through this loop, you would need to single-step 1000 times! To avoid this problem, there is the "super step." Once you have ascertained that a particular block of code is not the problem, you can use the "Super step" command, which executes a whole block (a loop, for example) of code at once. This would take care of the problem above very nicely. Or, you could set the program to stop executing at a certain point (set a breakpoint) and single-step or super-step from that point on. Debugging is considerably easier with this package.

ALICE-THE LANGUAGE
Alice seems to include all of what can be termed "standard" Pascal as defined by ISO. It also has quite a few extensions, both to allow for compatibility with Borland's Turbo Pascal, and "Watcom" (University of Waterloo, Ontario) Pascal. The string TYPE, as well as string operators for concatenating, finding, inserting and deleting strings are all present. Additional file handling commands are also included.

Another extension is that Alice supports no less than five graphics coordinate systems. Some of these will not be of interest to ST owners, since they are only there to provide compatibility with Turbo. But there are some very powerful systems, such as several versions of scaled coordinates. These provide coordinates which are independent of screen resolution or window size, and which can automatically scale your graphics to the window. The bulk of the extensions are for support of the ST's GEM operat-


With
a compiled
Pascal, you must
compile and link the
program, run it, and
attempt to figure
what might've gone
wrong. Alice will
change all that.


ing enviroment. This GEM support is quite good, although not as complete as some other languages. There are some commands for VDI graphics, such as setting fill patterns, sprites, shapes (ellipses, rectangles, etc.), plotting points and drawing lines, setting colors and text attributes, and handling the mouse. Many of the VDI graphics calls are missing, however. The publishers of Alice did not give them special commands because they say that many people won't use them, so why build them into the language? Instead, there is a library on the disk for a long list of VDI graphics calls, which you can include in your program. This does work, although, of course, you have to merge the library with your own program and declare the variables.

AES support is quite complete. Alice provides ways to build and use menus and alert boxes, as well as specify windows with all the attributes (title, sliders, close box, etc.) you need. Further, getting messages returned by GEM is made quite simple with the GETEVENT call and the EVENTPARAMETER function which holds the messages. The only problem with GETEVENT is that you can't specify which events you want to wait for. You must check the event after GETEVENT returns and see if it is the one you want to deal with. Information about the screen and current resolution is available in Procedure SCRXY. There is even a one-line dialog box, although currently there is no way to build your own dialog boxes with buttons, etc. or even to import one built with an RCS. Looking Glass says they are working on a library of procedures to do these. The AES support is unusual in how much Alice does for you. Normally, when a program receives a message from GEM that you want to move a window or slider, or redraw a window, the application must go into a loop and perform all of these housekeeping functions. Alice does this for you. If you click on the "move" bar and move a window, Alice will relocate the window, redraw it, and redraw any window under it. Alice will even take care of resizing if the user wants a window resized, removing much of the programming burden (and of understanding GEM) from the user.

THE ALICE MANUALS
The Alice manuals are good, although they could be better. I should point out that, as with most Pascal languages, the manuals assume you know Pascal, at least in its "standard" form. There are two manuals with Alice. The first is a tutorial, which introduces the syntax-directed editor. Work through the tutorial first, since it introduces many important concepts. The other manual is a reference book. The first part is pretty good, detailing additional information about the editor and its many commands, but it bogs down when it reaches the section about extensions and enhancements. The main problem is that it talks about the ways in which its extensions are different from either standard Pascal or Borland Turbo. At this point, though, you have no idea what the extensions do, since they're not introduced until the next section! Also, if you don't know Turbo, the sections on Turbo differences are tough going.

The section on programming with GEM is quite good, explaining about windows, menus and messages, with some code samples for you to look at. While it may not make you a GEM expert, there is enough information to get you going.

The real gripe I have with the manual is the alphabetical listing of extensions. Why do manual writers love alphabetical listings? The explanations of the extensions are decent, but related commands are spread out all through the section (depending on what letter they start with), so you have to to an inordinate amount of flipping back and forth. All the menu-related commands should be together, and all the window commands and message commands, too. The commands should also be listed in the approximate order they would normally be called in. A fne example of good GEM documentation is the OSS Personal Pascal manual.

ODDS AND ENDS
Currently, someone must own a copy of Alice if they want to run a program you have written. Looking Glass says they are working on a runtime package, which you can give out freely. They're also considering plans for a compiler, which would produce a .PRG file. The editor has an option for a compiler, but one is not yet available. A compiled program would also run much faster.

Also available is Alice Educator, a textbook for learning Pascal. Since it is designed for use with Alice, the different extensions (except for GEM) are also explained. This is one of the better Pascal texts I have seen, and well worth your money if you are serious about learning Pascal.

CONCLUSION
Alice-The Personal Pascal is an excellent implementation of (in my opinion) the best structured language ever developed. Because of the syntax-directed editor and Interpreter, it is ideally suited to beginners, although its power is sufficient for all uses where it makes sense to use Pascal. The Alice Educator is another plus for beginners, as is Alice taking over most of the hard work when it comes to GEM. The ease with which programs from the IBM PC written in Borland Turbo Pascal can be ported by using Alice cannot be ignored. It is not for everybody, though. It cannot currently be used for commercial development due to the lack of runtime package and/or compiler. It also lacks some of the more straightfoward GEM support present in OSS's Personal Pascal. But it is an excellent value, and if you want to learn Pascal, this package is definitely worth considering.

Alice-The Personal Pascal
Looking Glass Software
124 King St.
N. Waterloo, Ontario, Canada
N2J2X8
(519) 884-7473 $79.95
CIRCLE 226 ON READER SERVICE CARD