Lesson Notes By Weeks and Term - Senior Secondary School 2

Handling computer files

CLASS: SSS 2

SUBJECT: DATA PROCESSING

TERM: 2ND TERM

WEEK 3                                                                                                          Date…………………..

 

TOPIC: HANDLING COMPUTER FILES

BASIC OPERATIONS OF COMPUTER FILES:

Create: Creating a file with a given name.

Delete: Deleting a file that are unwanted.

Retrieve: Retrieving a stored file or lost file.

Copy: Copying a created file to either an external or in-built storage device.

View: Viewing a created file or granting privilege of viewing.

Open: Opening a file to use its contents.

Update: Reading or updating the contents.

Close: Closing the file, thereby losing access until it is opened again.

STEPS IN CREATING SEQUENTIAL FILE:

The OPEN statement is used in writing information to a file. In general, the open statement follows this pattern;

OPEN file FOR OUTPUT AS 1

The file determine the filename to use

The FOR portion indicates how the file will be accessed or operated; it may be APPEND, BINARY, INPUT, OUTPUT, and RANDOM

The AS is the identifier used for the file handle in question.

The following opens a file, using mode OUTPUT and number 1, and then saves the text.

10        CLS

20        OPEN “textfile.dat” FOR OUTPUT AS 1

30        PRINT 1, “Hello World”

40        CLOSE 1

50        END

CODE

The combination of all these records forms a file. Thus, a file is a group of related records.

To facilitate the retrieval of specific records from a file, at least one field in each record is chosen as record key. Usually, the key is unique to every record to avoid duplication of records in a file.

 

BASIC File Processing statement to read and display files

The table below would be used in a BASIC program. The table would be stored in a file named “EXAMFILE.TXT” the content would be retrieved from the file and output to the screen

 

 

 

 

 

MATHEMATICS

 

ENGLISH

 

TOTAL SCORE

01234

         50

         90

       140

01235

         70

         40

       110

01236

         80

         70

       150

Example

10        CLS

20        OPEN “EXAMFILE.TXT” FOR INPUT AS 1

30        PRINT 1 “MATRIC NO.           MATHS                       ENG. LANG        TOTAL SCORE”

40        PRINT 1 “     0001                    50                     90                                    140”

50        PRINT 1 “     0002                    70                     40                                    110”

60        PRINT 1 “     0003                    80                     70                                    150”

70        CLOSE 1

80        OPEN “EXAMFILE.TXT” FOR OUTPUT AS 1

90        DO WHILE NOT EOF(1)

100      INPUT 1, test

110      PRINT test

120      LOOP

130      CLOSE 1

140      END

Note that Free-File function is used to determine the next available file handle to be used in the OPEN statement. However, in a bigger project that uses many files, Free-file ensures that there is no conflicting File Handles used. It‘s a good practice to use it whenever you‘re not sure of the number of files your program might need to open.

  • OPEN “Examfile.txt” for output AS #File Number

This is the line that does the physical opening of file and assigns it #FileNumber as its file handle. The ‘FOR INPUT’ part tells QuickBASIC that you want to open the file in Read mode as you‘ll be reading the contents of the file later in the example.

Next is the loop indicate by the DO WHILE NOT EOF (FileNumber) line. In QuickBASIC EOF () means End Of File. There is also BOF () for Beginning of File and LOF () for Length of File

Since you can’t go backwards on a sequential file, you won’t need BOF () at all.

  • The first line Gets a line of data

DESCRIBE FILE INSECURITY

Computer file insecurity refers to the concept that a computer system is vulnerable to attack, and that this fact creates a constant battle between those looking to improve security, and those looking to circumvent security.

EFFECT OF INSECIRITY OF FILE

Data loss refers to the unforeseen loss of data or information. An occurrence of data loss can be called Data Loss Event and there are several possible root causes. Backup and recovery schemes are developed to restore lost data.

Overwriting is a process of writing a binary set of data on a memory. Overwriting generally occurs when unused file system clusters are written upon with new data. In simple terms, it writes over the previous data.

METHODS FOR FILES SECURITY

Backup

Backup or the process of backing up a file refers to making copies of files so that these additional copies may be used to restore the original after the data loss event.

Backup has two distinct purposes. The primary purpose is to recover data as a reaction to data loss, be it by data deletion or corrupted data. The secondary purpose of backups it is recover data from historical period of time within the constraints of a user-defined data retention policy.

Antivirus

An anti-virus program protects a computer file from malicious virus attack, detects and heals files that have been attacked. Usually it consists of a firewall, a virus scanner and remover and sometimes other tools as well.

Password

It is a chosen secret string of characters that allows access to a computer, interface, files etc. The use of password is at user’s discretion and caution must be exercised by the user to remember the password always.

Differences between computer files and manual files

Manual is using old method without the help of the technology or maybe less to perform certain task or work while; computerized file system is using latest technology of ICT to carry out various tasks that is more effective when compared with manual system in terms of the productivity and time usage.

 

EVALUATION

  1. State three advantages of computer files over manual files
  2. State five limitation of computerize file system
  3. List five operation that can be performed

Reading Assignment: Reading Assignment:

Hiit @ School, Computer Studies for Senior Secondary Education. Pgs 92 - 95.

 

WEEK THREE (3) WEEKEND ASSIGNMENT

OBJECTIVE

  1. ________ refers to the unforeseen loss of data or information.
  2. Backup b. Data loss      c. Overwriting  d. Antivirus
  3. _______ is the process of making copies of files, so that the additional copies may be used to restore the original after data loss event.
  4. Manipulating b. Data Loss Event c. Backup         d. Duplication
  5. An occurrence of data loss can be called ________________
  6. Data Loss Event        b. Data Loss Occurrence       c. Data Loss Show d. Data Loss occasion
  7. The following are limitations of computerized file system EXCEPT one.
  8. Vulnerable to virus attacks   b. Incompatible data file   c. Cheap to set it up   d. Data are often duplicated
  9. The following are advantages of computer files over manual files EXCEPT one
  10. Slow and inefficient in processing of information b. Accurate information and faster                                 decision making   c. Takes less space d. More timely information can be produced

 

THEORY

  1. Outline steps to be taken when creating a sequential file
  2. List and explain the three methods for files security


© Lesson Notes All Rights Reserved 2023