Handling Computer Files

 

Welcome to class! 

In today’s class, we will be talking about handling computer files. Enjoy the class!

Handling Computer Files

Handling Computer Files | classnotes.ng

Basic operations of computer files

  1. Create:  Creating a file with a given name.
  2. Delete:  Deleting an unwanted file.
  3. Retrieve:  Retrieving a stored file or lost file.
  4. Copy:  Copying a created file to either an external or in-built storage device.
  5. View:  Viewing a created file or granting privilege of viewing.
  6. Open:  Opening a file to use its contents.
  7. Update:  Reading or updating the contents.
  8. Close:  Closing the file, thereby losing access until it is opened again.

Steps in creating sequential files

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 determines 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 filehandle 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 a 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 filehandle to be used in the OPEN statement. However, in a bigger project that uses many files, Free-file ensures that there are 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 filehandle. 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 indicated 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.

Effects of insecurity of files

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 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 file 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 to recover data from a 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 a password is at the 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 the old method without the help of the technology or maybe less to perform a certain task or work while; computerized file system is using the latest technology of ICT to carry out various tasks that are more effective when compared with a manual system in terms of the productivity and time usage.

General 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

Weekend assignment

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

 

In our next class, we will be talking about Word Processing.  We hope you enjoyed the class.

Should you have any further question, feel free to ask in the comment section below and trust us to respond as soon as possible.

For more class notes, homework help, exam practice, download our App HERE

Join ClassNotes.ng Telegram Community for exclusive content and support HERE

Leave a Reply

Your email address will not be published. Required fields are marked *

Don`t copy text!