This chapter extends the explanation
of
how
to
use the Archive programming language
by describing how
to
work with two
or
more open
files.
When
you
have more than one
file open
at
the same time
you
must be able
to
Identify which
file
you
want
to
use for
any particular operation.
You
must give each
file
a unique logical file
name
when
you
open or create
It
and then
refer
to
It
by
that name
in
all
commands that refer
to
the
file.
Archive automatically supplies the logical
file
name,
"main",
when
you
open a single
file.
It
is
called a logical
file
name
to
distingUish
it
from the phYSical file name - the name
you
give
to
the
file
when
you
save
it
Since a program refers
to
a
file
by
its
logical
file
name,
you
can write a program that
will work with several different
files.
Logical
file
names are essential for multiple
file
operations
Since
you
can only open a
second
file
by using both
ItS
phySical
file
name and
its
logical
file
name.
Note that the
logical
file
name
is
not saved
with
the
file
when
it
is
closed and must be specified each
time the
file
IS
opened.
Two
or more data
files
could contain fields with the same name. When
thiS
happens
you
can idenlify the
file
to
which the field belongs
by
adding the logical
file
name
to
the field name. For example,
If
the field country$ appears
In
two
files
whose logical
file
names are
"main"
and
"b"
you
could
refer
to
each of them respectively
as
"main.country$"
and "b.country$':
The
first
example demonstrates how
to
add, delete or rename fields within
an
existing
file.
Suppose that
you
want
to
make some changes
to
the 'gaze!"
file,
to
create a new
file
containing only European countries. The 'tontlnent$" field becomes irrelevant and
we
need not Include It
We
shall also rename the "pop" field
as
"population':
The most convenient way of changing the
file
is
to
create a second
file
containing the
fields you want and then
to
copy the required records from the old
file
to
the new
one.
Let
us
call the new
file
'europe': The following procedure
will
do
the
rest
of the work.
proc
start
rem
*****
c
reat
e
eu
rope
f;
t e
*****
create
"europe"
logicaL
lie"
country$
capital$
languages$
currency$
popuLation
gdp
area
endcreate
Look
"gazet
ll
Logical
"g"
seLect
continent$="EUROPE
II
all
"g"
print
at
O,O;g.country$;tab
30
Let
e.country$=g.country$
let
e.capital$=g.capital$
let
e.language$=g.language$
Let
e.currency$=g.currency$
let
e.population=g.pop
let
e.gdp=g.gdp
let
e.area=g.area
append
"
e
"
endall
cLose
lie"
cLose
"g"
print
print
"DONE"
endproc
12/84
CHAPTER
11
USING
MULTIPLE
FILES
LOGICAL
FILE
NAMES
CHANGING
THE
RECORDS
OF
A
FILE
31