ACCESS A SEQUENTIAL FILE
ACCESS A SEQUENTIAL FILE
Data stored in a sequential file can read in order and assigned to
variables with the following steps:
1.
Choose a number from 1 through
255 to be the reference number of the file. This number is not necessary to be
the same number that was used when the file was recorded.
2.
Execute the statement
OPEN filename FOR INPUT AS #n
Where n is the reference number. This
procedure is referred to as opening a file for input. It establishes a
communication line between the computer and the disk drive for reading data
from the diskette.
3.
Read data from the file with
the INPUT* statement. INPUT* statement assigns data from file to variable.
INPUT #n. var1, var2, ……
4.
After the desired items have
been found or all the data has been read from the file, close the file with the
statement CLOSE #n.
5.
Basic function EOF; it tells us
if we have reached the end of a file. For example the condition EOF (n) will be
true if the end of file n has been reached and false otherwise.
EXAMPLE: Write a program to display a
table showing the ages in 1991 of the people in the sequential file YOB.DAT.
Solution
REM Process data from YOB.DAT file to
find ages in 1991
CLS
OPEN “YOB.DAT” FOR INPUT AS #5
PRINT “NAME”, “Age in 1991”
DO WHILE NOT EOF (5)
REM Process the entire file
INPUT #5, name$, year
PRINT name$, 1991 – year
REM Display name and age in 1991
LOOP
CLOSE #5
END
[run]
Name Age
in 1991
Barbra 49
Ringo 51
Sylvester 45
Johnny 65
PROTECTING FILES
Many
modern computer systems provide methods for protecting files against accidental
and deliberate damage. Computer with multi users implement file permissions to
control who may or may not modify, delete or create files and folders. A user
may be given permission to modify a file or folder, but not to delete while
some may be permitted to only read the contents and not permitted to modify or
delete the content.
FILE INSECURITY
File
security is a feature of your file system which controls which users can access
which files, and places limitations on what users can do to files.
Effect
of file insecurity
(a) Data
loss: Computer users and many experts often loss data permanently destroyed,
with no hope of recovery.
Causes
of Data loss
Causes of Data Loss
|
Customer Perception
|
Human error
|
40%
|
Computer viruses
|
15%
|
Natural Disasters
|
3%
|
Hardware or System Problem
|
28%
|
Software Corruption or Program Problem
|
12%
|
(b) Overwriting
This is
a process of writing a binary set of data on a memory. Data that has been
overwritten is generally considered to be unrecovered.
FILE
SECURITY METHODS
(i) BACK
UP: This is refers to making copies of data so that these additional copies are
used to restore the original after loss event. It is also a method of making
copies of the file in a separate location so that they can be restored if
something happen to the computer. This can be done by using removable media
such as rewritable CD, memory card, flash etc.
(ii)
VIRUS: This is a self – replicating program that copies itself and that can
infect other programs by modifying them or their environment such that a call
to an infected program implies a call to a virus.
ANTIVIRUS:
This is software to protect your computer from viruses that may try to infect
your computer or might have done so.
(iii)
PASSWORD PROTECTION: It can prevent people accessing computer system, account
files or parts of files by requiring a user to enter password.
(iv)
STORAGE DEVICE LABELING: You should label your storage devices like floppies,
CDs, DVDs, Pen drivers etc. So that you know what is exactly stored in them and
so as not to accidentally delete of format them.
ADVANTAGES OF
COMPUTERIZED FILES
(i) Computer can
form calculations quickly and efficiently.
(ii) Data can be
retrieved quickly and easily.
(iii) Documents
that are lost can often be retrieved.
(iv) Security is
tight and hard to break into.
(v) Makes work
easier.
(vi) Quicker to
find things and sort things.
(vii)
Transactions, accounts can be handled more properly by computers than manually.
LIMITATIONS OF
COMPUTERISED FILES
(i) Computerized
filing system is expensive to set up.
(ii) Not effective
where there is irregular electric supply.
(iii) Skilled
labor with proficiency in computers is required.
Comments
Post a Comment