General Principles of Alice

The easiest way to learn how to use Alice is to start Alice up and experiment with the various features. In the next chapter, we will walk through a sample Alice session and guide you through some sample operations. Before we do that, however, we should cover some of the basics of what Alice is about.

The Editor

You are probably familiar with the idea of creating the source code of a program with an editor. With Alice, you use a special kind of editor called a program editor. This is an editor that is specifically designed to create programs in Pascal.

With most editors, you must type in your program line by line. With Alice's program editor, you can approach your program in a completely different way. You construct your programs out of Pascal's natural building blocks. For example, suppose you want a while statement in your program. You begin by typing the keyword while. When the Alice editor recognizes the keyword, it immediately displays the following on the screen:

Screen Shot 6 8 whiletemp not available

This is the skeleton or template of a while statement in Pascal. The underlined words are empty placeholders showing things that you have to fill in to get a complete while loop. Alice's placeholders are always underlined so they are easy to recognize. You could fill in the Condition placeholder with an ordinary condition like:

i < 10

When you fill in the Statement placeholder, you can enter one or more normal Pascal statements. For example, you might begin with an if statement. Again, as soon as you type the keyword that begins the statement, Alice will lay out a template:

Screen Shot 6 8 iftemp not available

In this way, you are always seeing your program as a sequence of logical blocks instead of mere lines of text.

Because the editor lays out most of your source code for you, it is almost impossible to make syntax errors with Alice. You never have to worry about balancing begin and end statements because Alice balances them for you. The editor also catches a number of other errors as you enter your program, e.g. undeclared variables. If you make this kind of mistake, Alice immediately gives you an error message and highlights the error on the display screen. This gives you a chance to correct the error immediately. You can also leave the error for a while and come back to it when you are ready to fix things up.

In short, the editor ensures that you always have a syntactically correct program every step of the way. This means that you can stop worrying about trivial typing areas and concentrate on what is important: your program's logic.

The Interpreter

The Alice interpreter can be used to run your program once you're finished entering or editing it. As you enter source code, the editor converts the code to a special internal format that is simpler (from the standpoint of the machine). The interpreter works with this machine format and can thus work more quickly than interpreters that have to work on the original source code.

The Debugger

The debugger works hand-in-hand with the interpreter and editor to help you find and correct problems in your program. The debugger lets you do such things as

  1. execute your program one instruction at a time
  2. put ``breakpoints'' in your program so that execution stops when it gets to a particular instruction
  3. zip the cursor through the source code displayed on the screen as your program executes -- the position of the cursor indicates what statement is being executed at any time, and the motion of the cursor gives a clear indication of the flow of control inside the program

The Help Facility

The Help facility offers a wide selection of help on the use of Alice, the features of Pascal, programming concepts, the meaning of error messages, and many other topics. You can press [F9] practically any time to obtain help on what you are doing.


Throughout the rest of this guide, we will use a number of shorthand conventions to make things simpler.

We use the term subprogram when something can be either a Pascal function or procedure. The term routine will also be used for this purpose.

When we write [F1], [F2], [F3], ..., we are referring to the function keys that run along the left side of the PC keyboard.

When we write [SHIFT-something], we mean that you should hold down one of the [SHIFT] keys, then press another key on the keyboard. For example, [SHIFT-TAB] means you should hold down the [SHIFT] key, then press [TAB]. For example, [SHIFT-F1] means that you should hold down a [SHIFT] key and press the key labelled [F1].

When we write [CTRL-something], we mean that you should hold down the [Ctrl] key and press some other key. For example, [CTRL-U] means that you should hold down the [CTRL] key and press the ``U'' key.

When we write [ALT-something], we mean that you should hold down the [Alt] key and press some other key. For example, [ALT-H] means that you should hold down the [ALT] key and press the ``H'' key.

Alice tries to represent different pieces of source code in different ways. If you have a colour display screen, the following colours are used.

normal text:white
placeholders:bold blue
errors:bold red
keywords:bold white
named constants:white
user subprogram names:bold green
built-in subprogram names:cyan
record field names:white
undefined symbols:reverse video magenta
expressions being edited:bright green

While it's unlikely you would have one today, on systems with the ``monochrome display adapter,'' the defaults are

errors:reverse video
undefined symbols:reverse video
expressions being edited:underlined
everything else:normal

If you are using the ``colour/graphics display adapter'' with a non-colour (black and white) monitor, placeholders and expressions being edited are shown in boldface. In this tutorial, we will generally use the term ``highlighted'' to mean that something on the screen stands out somehow. If you have a colour screen, it will be shown in a special colour. If you have a monochrome screen, it will be shown in reverse video.