-
Notifications
You must be signed in to change notification settings - Fork 0
/
ap1.dem
233 lines (233 loc) · 11.2 KB
/
ap1.dem
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
/c/
Welcome to ALICE Pascal, an entirely new way to program and a new way to
learn programming. Unlike other systems, ALICE works with computer programs
AS PROGRAMS, not as listings. It's called a "syntax-directed editor"
because it knows the syntax and rules of the Pascal language intimately.
/C/p/c/
ALICE starts up with a menu offering to write a new program, work on
an old one, or get help about the system. ALICE is easy to learn, and
can be fully used from menus, so you don't have to remember a million new
things. We're going to now select "Edit a New Program."
/p/c/s //
What you see on the screen is what we call the "template" of a Pascal program. All the structure has been filled out - you just have to "fill in the blanks"
to get a working program. This demonstration version will now start doing
this, under your guidance.
/p/cIn order to run this demo, ALICE will fill in the keystrokes that would
be typed to use the program. So you can run things at your own pace, whenever
it is time to press a key, ALICE will wait for you to hit any key, like SPACE.
When you do, ALICE will show what key is being typed, and it will act as
though the you had pressed this key./
/p/c/
As an example, of ALICE, we're going to enter a FOR loop by typing "for "
where it says "Statement". Hit the space bar repeatedly and watch carefully:
/k{for /
/p/cThe system should now have displayed the "template" for the Pascal FOR loop,
with four "blanks" to be filled in. You'll note that ALICE provided all the
words, indentation and punctuation. ALICE always does this, and that means
it's essentially impossible to have a syntax error!
/p/c/
We call these blanks you fill in "placeholders" and the cursor is now on a
placeholder called "Variable". That means a variable should be typed
in here. We'll enter one called count:
/k{count /
/p/cIn Pascal, every variable you use must be declared first. Notice how
ALICE spotted that we hadn't declared "count" as soon as it was entered.
ALICE spots all such "semantic" errors as soon as they are typed in.
We'll fix that error later. In the meantime, let's fill in the rest.
/p/cWe will make a simple loop from one to ten:
/k{1 /
Notice how ALICE lets you move from placeholder to placeholder with keys like
TAB - reducing keystrokes and errors.
/p/cIn addition, you can use the keywords of Pascal to move you around, if
these are more familiar to you.
/k{10 do /
/p/cNow it is time to type in the statements in the FOR loop. If you don't
know Pascal well, here's where ALICE can really help you. ALICE contains the
most complete HELP system ever included with a programming tool. All this
help, and in fact all ALICE features, can be obtained from a menu.
/p/cWe will hit the important help key, and select the menu item called
"What can I type now?" which lists all possible input at any given point.
/k/h/d/d/d/d{ /
/p/c/
You now see a menu including all the statements in Pascal. We will pick
an IF statement from this menu.
/k/d/d{ / Now the IF statement has appeared, picked off a menu.
If you like you can write your entire program using menus for all but the
variable declarations and constants. /p/c/
Now that we have the IF, we'll see more of the help ALICE has to offer:
/k/h/d/d/d (Information about Pascal) { /
This menu lists features of Pascal, and in particular the ones that are
being used right now. For help on FOR loops, just select and watch:
/k{d//p/cHere's a screen that explains FOR loops, giving examples. There is
a similar screen for every part of the Pascal language, and they're all
as easy to get to. Each help screen is cross referenced to related topics,
in this case, for example, the variant of the FOR loop that goes backwards.
We'll select "Do nothing" and go on editing. /p/s //
/cWe didn't really want the if, so we'll use the full UNDO of ALICE to get rid
of it. In fact, we can undo all we have done so far. Let's go back to
the very start with the UNDO key.
/k{ //p/c/
And now we will "undo our undo" with the REDO key
/k{/
All but the IF will now be back./
/p/c/
It is time to declare "count". Watch as we type the Pascal 'VAR'iable keyword
and ALICE figures out where that should go.
/k{var count in/
We're in the middle of typing "integer" and can now do something really
amazing./
/p/c/
We're going to ask ALICE to finish off this symbol for us just by hitting the
"Symbol-End" key, marked "End" on the keypad.
/k/i{ / - ALICE saw the only type starting with "in" was
"integer", and filled it in for us. This works with the symbols you define,
too, as you will soon see./p/c/
We'll quickly fill in a comment:
/k{Loop Counter //d
And now we are ready to complete our simple program
/k{writeln(count,sqr(count),sqrt(c//
/p/c/
We'll ask to complete the symbol again.
/k/i - this time we get a menu of all possible symbols that
start with 'c', including "count." We will pick it and go on.
/k/d{ ))/ - The final ")" shows the writeln call is done.
/p/c/
If you aren't surprised at what ALICE can do already, watch as ALICE
immediately runs your program at the touch of a key.
/k/f1
Below you now see the output of our simple program.
It's that simple!/
/p/c/s //
Now we'll load in an existing program to show you more about the ALICE
system. We're going to load "sieve.ap" which is a program that
generates prime numbers using the "Sieve of Eratosthenes." It's
a popular test program used by many magazines./
/p/c/
/sload sieve.ap
B//
To show you a fancy debug feature we're going to turn on what we call
"cursor following." This will split the screen into two parts, one for
editing and one for output.
/k/f6{J//
/p/c/
Now we will run the program and see an amazing "motion picture" of the
program in action. The cursor will actually follow what the program is
doing on the screen!
/k/f1/p/c/
ALICE lets you do all sorts of other useful debugging stuff, too. There's
single stepping, tracebacks, breakpoints and an immediate mode that lets you
examine and change variables. It's all integrated right into the editor, so
there are no delays or new commands to learn./
/p/c/
ALICE has a special new variable tracing feature that lets you track all
changes to interesting variables in your programs. ALICE really knows what
your program is about, and this helps you debug. You'll be removing
those hard-to-find bugs from your programs in no time./sbugoff
//
/p/c/
ALICE is geared to help you structure your program and to aid in top-down
design. To do this, it lets you "hide" unimportant parts of your program
so that they don't get in the way of other work. For example, in this
program, the first few lines are an initialization loop. We're going to
"hide" that part of the program./
/p/c/
First we'll go to the start of the program:
/k{begin /
Now we'll "sweep out" the part of the program we want with the SELECT key
/k/f:/d/
/p/c/
(Notice how ALICE insists you select only a valid program element. You can't
have the FOR without the whole loop.) Now we will HIDE this part...
/k/f5{D/ - and it gets compressed to three dots ... and a comment.
/k{Init loop//t/
/p/c/
To look at what's inside, we will ask the program to "reveal" it.
/k/u/f5{E/ - and now you see it. You can have hidden things within
hidden things - structuring your program the way you want it.
We'll continue to use this "sieve" program for our future editing examples./
/p/c/
The HELP you saw before was just a fraction of the over 600 help screens
ALICE has to help you learn ALICE and Pascal. For example, there's a help
screen for every error message the system has. Let's create an error:
/k{
count 1+'a'
//p/c/
ALICE reports all type-mismatch and semantic errors, too. For full details
on what this one means we will use the HELP system.
/k/h (selection H){H/ There's a screen like this for every message.
You will notice the help is also cross referenced to several related topics,
in case you need more information/
/p/c/
We'll ask about real numbers
/k{C/ and get back to our program. /k{ /
The help doesn't stop there. You can get help on every command feature and
menu selection in the ALICE system. There's help on every placeholder and
language element in Pascal./
/p/c/
There's also help on every built-in procedure, function and predefined type
of the ALICE system. This is also all supplemented by over 500 pages of
written documentation, including a complete textbook that teaches you how
to program from the ground up using the ALICE system./
/p/c/
Now we're going to show you a few quick editing examples to display the true
power of ALICE editing. Watch as one command changes an IF statement into
a WHILE loop.
/k/d/d/d/d/d/d/d/d/d/d/d/d/u/u/u/u/u/f:/f5{ID/
/p/c/
Notice how when we call up any procedure, we are prompted with the parameters:
/k{
delete /
This happens for your own procedures too, and of course all the types are
checked as you type in the arguments./
/p/c/
ALICE 1.3 has most of the Pascal extensions found in Borland International's
Turbo Pascal(TM), including strings, graphics, sound, windows & screen access,
pre-initialized variables, machine-code libraries, binary operators, untyped
parameters and more. You can use ALICE to help you learn about (and write and
debug programs for) Turbo Pascal./
/p/c/
This DEMO version can't save programs or read in normal text programs, but
the real ALICE is not limited in this way. A companion program called APIN
converts programs from readable text format into ALICE .AP format, and another
program called APRUN lets you run your programs without loading the ALICE
editor./
/p/c/
ALICE is macro-driven and programmable (in Pascal, of course!) so you can
customize it to suit your needs, giving you almost unlimited power.
To conclude this demonstration, we'll go to another workspace (yes, you can
edit several programs at once) and show you how many keystrokes (and errors)
you can save using ALICE to enter a simple program./
/p/c/
/sws newprog
/We're going to make a program that reads in a list of numbers and prints
the average. (You may want to hold the SPACE bar down for this one.)
/k{var total,how_many,valuetemp i//i{
loopcounter i//i/t/t{write '//'how many numbers? '/{
readln(h//i{
to//i{ 0;for l//i{ 1//t{h//i{
write('//'number '/{,lo//i{,'? '
readln(va//i{
to//i{ to//i{ + v//i/t/d{
?'//'Total is'/{,to//i{,' //'Average is'/{,total div ho//i/t/
/p/c/
This concludes the demonstration. You can now play with your demo version
of ALICE, which lets you do everything except save a program. Have fun!
Educators can contact us at 1-800-265-2782 (519-884-7473) to discuss
site license terms or to purchase a regular copy. Do not contact
Software Channels Inc./
/p/c/T/
By the way, if you didn't run this demonstration on a color display, find
one and try it. ALICE uses color to show semantic information about your
programs, and this makes them easier to understand. No other system can
do this because no editor knows as much about a program as ALICE./
/p/c/
To play with the system now, including the program that was just input,
press the dot key (".") on your keyboard. Once inside, you can quit with
the menu on the F8 key, or by pressing "Alt" and "Q" at the same time.
/Q/c/
If you want to play with the system later, just start it up again by typing
"alice". Play with the sample programs on this disk, and print the file
ALICE.DOC on your printer for more detailed information. Remember the
HELP key - F9 on your IBM-PC keyboard.
Goodbye./
/p/c