CHAPTER
8
PROCEDURES
CREATING
A
PROCEDURE
LISTING
AND
PRINTING
PROCEDURES
16
To
use the examples
In
this chapter,
first
type new
to
clear the computer then type look
"gazel"
to
open the example
file
on
your data cartridge, which
IS
assumed
to
be
in
Microdrive
2.
The commands and functions
of
Archive together form a programming language which
you can
use
to
write programs that
will
manipulate your
files.
You
will
find that Archive
programs are simple
to
write.
An Archive program
IS
made up
of
one or more separate sections. Each section
is
known
as
a procedure which
is
Simply a named section of program.
You
can refer
to
a procedure by
ItS
name,
like the procedures which
you
write and use
In
SuperBASIC.
In
Archive
you
can
run
a procedure
by
typing
ItS
name
at
the keyboard. When you
write a procedure
you
are effectively adding a new command
to
Archive
No procedure may contain more than 255
lines,
and each line must not contain more
than
160
characters.
You
use the program editor whenever
you
want
to
write or change a proced,ure. This
editor allows
you
to
change, delete or add
to
the text of procedures.
The program editor
is
described
In
detail
in
Chapter
9,
but
in
this chapter we will look
briefly
at
some
of
ItS
features
so
that
we
can
write
a
few
short procedures.
We
shall
assume
that initially there are no procedures
In
the computer's memory.
Type:
edit
to
enter the program editor The control area changes, showing that
you
should type
in
the name
of
the procedure. Entering the editor
will
always allow
you
to
create a new
procedure
If
none are defined or loaded.
The first thing
to
do,
therefore,
IS
to
decide what the new procedure should do.
Let
us
start
With
a very
Simple
task;
to
make
life
easier by renaming the display command.
We
will
save
typing by giVing
It
the name
'd':
Just type
d
The left hand side of the display area now shows the name, and the right hand
Side
a listing of the procedure. The procedure,
as
yet.
contains no commands; the proc and
endproc which mark the beginning and end of the procedure were automatically added
by Archive.
The
body
of the procedure must be added; that
IS
sequence of actions
it
IS
to
perform.
The control area shows that
you
can add lines of
text
to
the new procedure.
In
terms
of the current example
thiS
text
IS
the display command.
Type:
display
and Archive will Insert the new
text
into the procedure below the highlighted
line.
If
you
have followed
thiS
example the display
will
contain:
d
proc
d
display
endproc
You
could add more lines
of
text
- each
line
would be inserted below
the
highlighted
line.
In
thiS
case,
however the procedure
is
complete
so
you can
leave
the edit command
by pressing ESC twice.
All
you
have
to
do
to
use the procedure
is
type
its
name, followed
by
ENTER. This new
procedure will perform the same function as typing the command display
in
full.
Whenever
you
call
the edit command
you
are shown a
list
of the names of
all
the defined
procedures present
in
the computer's memory.
12/84
•
•
•
•