Home » HANDLING COMPUTER FILES

HANDLING COMPUTER FILES

BASIC OPERATIONS OF COMPUTER FILES

File Operations: These deal with the physical movement of data in and out of files. User programs effectively use file operations through appropriate programming language syntax The File Management system manages the independent files and acts as the software interface between the user programs and the file operations.

 

Operations

A) Insertion: Records must be inserted at the place dictated by the sequence of the keys. As is obvious, direct insertions into the main data file would lead to frequent rebuilding of the file. This problem could be mitigated by reserving overflow areas in the file for insertions. But this leads to wastage of space and also the overflow areas may also be filled.

 

B) Deletion: Deletion is the reverse process of insertion. The space occupied by the record should be free for use. Usually, deletion like insertion is not done immediately. The concerned records written to a transaction file. At the time of merging the corresponding data, record will be dropped from the primary data file.

 

C) Updation: Updation is a combination of insertion and deletions. The record with the new values is inserted and the earlier version deleted. This is also done using transaction files.

 

D) Retrieval: User programs will often retrieve data for viewing prior to making decisions, therefore, it is vital that this data reflects the latest state of the data if the merging activity has not yet taken place.

 

E) Open.

 

F) Close.

 

G) View.

 

H) Copy.

 

I) Creation.

 

CREATING AND ACCESSING SEQUENTIAL FILES

Sequential files are easier to create than random access files, but are limited in flexibility and speed when accessing data. Data written to a sequential file is a series of ASCII characters. Data is stored, one item after another (sequentially), in the order sent. Data is read back in the same way.

Creating and accessing random access files requires more program steps than sequential files, but random files require less room on the disk, because GW-BASIC stores them in a compressed format in the form of a string.

 

Creating a Sequential File

The following statements and functions are used with sequential files:

 

The following program steps are required to create a sequential file and access the data in the file:

1) Open the file in output (O) mode. The current program will use this file first for output:

OPEN “O”,#1,”filename”

 

2) Write data to the file using the PRINT# or WRITE# statement:

 

3) PRINT#1,A$

 

4) PRINT#1,B$

PRINT#1,C$

 

5) To access the data in the file, you must close the file and reopen it in input (I) mode:

 

6) CLOSE #1

OPEN “I”,#1,”filename

 

7) Use the INPUT# or LINE INPUT# statement to read data from the sequential file into the program: INPUT#1,X$, Y$,Z$

 

Accessing a Sequential File

A program that creates a sequential file can also write formatted data to the diskette with the PRINT# USING statement. The LOC function, when used with a sequential file, returns the number of 128-byte records that have been written to or read from the file since it was opened.

 

Adding Data to a Sequential File

When a sequential file is opened in O mode, the current contents are destroyed. To add data to an existing file without destroying its contents, open the file in append (A) mode.

 

RANDOM ACCESS FILES

Information in random access files is stored and accessed in distinct, numbered units called records. Since the information is called by number, the data can be called from any disk location; the program needn’t read the entire disk, as when seeking sequential files, to locate data. GW-BASIC supports large random files. The maximum logical record number is 2³² – 1.

The following statements and functions are used with random files:

 

Creating a Random Access File

The following program steps are required to create a random data file:

1) Open the file for random access (R) mode. The following example specifies a record length of 32 bytes. If the record length is omitted, the default is 128 bytes. OPEN “R”, #1, “filename”, 32

 

2) Use the FIELD statement to allocate space in the random buffer for the variables that will be written to the random file:

FIELD#1, 20 AS N$, 4 AS A$, 8 AS P$

In this example, the first 20 positions (bytes) in the random file buffer are allocated to the string variable N$. The next 4 positions are allocated to A$; the next 8 to P$.

 

3) Use LSET or RSET to move the data into the random buffer fields in left- or right-justified format (L=left SET;R=right SET). Numeric values must be made into strings when placed in the buffer. MKI$ converts an integer value into a string; MKS$ converts a single-precision value, and MKD$ converts a double-precision value.

 

4) LSET N$=X$

 

5) LSET A$=MKS$(AMT)

LSET P$=TEL$

 

6) Write the data from the buffer to the diskette using the PUT statement:

 

Accessing a Random Access File

The following program steps are required to access a random file:

1) Open the file in R mode:

OPEN “R”, #1, “filename”, 32

 

2) Use the FIELD statement to allocate space in the random buffer for the variables that will be read from the file: FIELD, #1, 20 AS N$, 4 AS A$, 8 AS

 

FILE SECURITY

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. For example, a file may be secured so that everyone can view it but only certain specific people may change it, while another is secured so that only the owner may view it. Folders may also be secured in this way. Users of Windows 95 or Windows 98 may not have encountered file security before, because the FAT file system does not support file security. Users of Windows NT who have NTFS volumes may be familiar with file security, because NTFS supports this feature.

File security consists of two key elements: authentication and permissions. Authentication is how the computer finds out who you are you tell it this by providing a username and password when you begin using it, also known as “logging on”. Permissions are the properties of a file or folder that specify who can access it (a list of users) and how (the type of access they are allowed). Normally, you modify the permissions of a file or folder from its properties dialog in the Windows Explorer.

Whenever a user accesses a file or folder, the file security feature kicks in. This is called an access check. The file system considers the user’s identity, and what kind of action the user is performing, and consults the file’s permissions. If the permissions do not allow the action, the user gets an “Access Denied”. error.

 

EFFECTS OF FILE INSECURITY

  • Data Loss.
  • Overwriting.

 

METHODS OF FILE SECURITY

  • Use of back – ups.
  • Use of Anti-virus
  • Password.
  • Proper label of storage devices.

 

DIFFERENCES BETWEEN COMPUTER FILES AND MANUAL FILES

 

Computer Files

  1. Computer files are easily accessible. Documents can be located by having the computer search large numbers of documents for specific words or phrase.
  2. Computer files are environmental friendly.
  3. Computerized filing system can store a huge number of documents in a tiny fraction of space in computer memory.
  4. Files in a computer system can be encrypted to render them unreadable by those without authorized permission.
  5. Copies of computerized files can be easily created and stored in various location, thereby reduce time in creating more copies.
  6. A document on computerized system can be easily shared by attaching the document to an email sent to the recipient.

 

Manual Files

  1. Manual files are not easily accessible.
  2. Manual files are not environmental friendly.
  3. Manual files required a lot of spaces for storing huge number of documents
  4. Manual files cannot be encrypted.
  5. A lot of time is required in creating copies of documents.
  6. Manual files required making physical copies of the document and then mail them to the recipient, thereby consume time.

 

ADVANTAGES OF COMPUTERIZED FILES

  1. More secured.
  2. Fast to access.
  3. Less laborious.
  4. More reliable.
  5. Neatly modified.

 

LIMITATIONS OF COMPUTERIZED FILES

  1. Irregular power supply.
  2. Expensive to set up.

Leave a Reply

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

×

 

Hello!

Click one of our contacts below to chat on WhatsApp

× How can I help you?