Using
MLilipie
F~es
THE
CURRENT
FILE
You
can
see,
from this example, that you can
use
the
same name for a field
in
both
files
- they can be distinguished
by
including
the
logical
file
name.
If
you
do
not include
the logical
file
name then
it
will be assumed that the current file
IS
to
be used. The
last
file
to
be opened automatically becomes the current
file.
In
thiS
example the current
file
will
be 'gaze!" (with logical
file
name 'g')
so
we
could make use
of
thiS
by simply
writing the g before the field name
in
the previous program.
If
you
do
not Include the logigal
file
name
in
any case where
it
is
optional, Archive
will
assume
that
the command
refers
to
the current
file.
It
IS
usually safer
to
include the logical
file
name
expliCitly,
to
avoid any possibility of confusion.
You
can,
at
any
time,
speCify the current
file
by means of the use command.
If
you
Included the command:
in
the above
example,
then
"europ~'
would be the current
file
until
you
changed
it
again,
either
by
opening another
file
or
by
means of the use command.
STOCK
CONTROL
Now for a more complex example.
In
a stock control
system
you
will need
to
Find information
on
a particular stock
Item.
Obtain a report
on
the current stock levels of
all
items.
Record sales and modify the stock records accordingly.
Order new supplies,
to
maintain adequate stock
levels.
Record deliveries of stock.
You
will
obviously need a
file
to
hold the details of
all
items held
in
stock and
it
is
convenient
to
have a second
file
to
hold details of
all
your suppliers.
You
will need
to
be able
to
access either
file
from the other - tor example
you
may want
to
know
all
the possible
suppliers of a particular
item,
or
to
find out what items are supplied by a particular
company.
In
order
to
keep the application
as
simple
as
possible
we
shall not use the menu-driven
approach of the examples
in
the previous two chapters.
We
shall
write
it
as a series
of separate commands which can be used - like the standard commands - by typing
their names.
Since the procedures
will
be strongly dependent on the
file
structure
we
use,
we
must
first give some thought
to
their appearance.
The Stock File The stock
file
must contain
full
details of the stock situation for each item. The following
list
explains
all
the fields we shall
use.
Field Name
Use
Example
stockno$
The internal stock code
A101
description$
Item
description
Widget,
La
rge
qty
Number
in
stock
500
se
llpr
Selling price
1.
25
reorder
Lev
Reorder when stock
200
level
falls
below this
value.
buyqty
How many
to
order
400
We
can create the
file
by:
create
"stock"
LogicaL
"sto"
stockno$
description$
qty
reorder
Lev
sellpr
buyqty
endcreate
The
Supplier
File
This
file
holds the names, addresses and telephone numbers of the companies that
supply the goods
you
sell.
It
will be useful also
to
include the name of a contact person
In
the company.
In
order
to
be able
to
access this information efficiently
we
shall include
a code for each company.
We
shall use the following fields:
32 12/84