sign in
 
   
 
 
 
   
  COBOL TUTORIAL FOR BCA STUDENTS OF M G UNIVERSITY  
  UNIT 5: SEQUENTIAL FILES AND FILE PROGRAMS  
   
  INTRODUCTION  
   
 

A sequential file is a file whose records can be accessed in the order of their appearence in the file. This logic of accessing the records in a sequential manner is independent of the medium used to store a sequential file. A magnetic tape file, a card file or a printer file can only have a sequential organization. On the other hand, a disk file can have different organizations such as indexed, relative and sequential organizations.

 
  FILE CHARACTERISTICS  
 

The task of file handling is the responsibility of the system software known as IOCS
(Input-Output control system).


 
 

RECORD SIZE

 
 

The record of a card file must consist of 80 characters and those for a print file consist of 80 or 132 characters, depends on the model of the printer. On the other hand the size of a tape or disk file may be chosen by the programmer. Although any suitable size can be fixed for the records in a tape or disk file, the choice is subject to certain limitations imposed by the computer system and its IOCS. A sequential tape or disk file can contain either fixed or variable-length records. In most applications fixed-length records are used.

 
  BLOCK SIZE  
 

While handling a tape or disk file, normally a single record is not read or written. Instead, the usual practice is to group a number of consecutive records to form what is known as a block or physical record. The actual handling of blocks is transparent to the programmer. The IOCS takes care of the blocking. The programmer should only specify the number of records that should be contained in a block. When a file is blocked, a physical read or write operation on the file is only applicable to the entire block and not to the individual records in the block.

The IOCS reserves a memory space equal to the size of a block of the file. This memory space is known as the buffer. The records as defined in the program are sometimes called logical records and the blocks which are records as stored on the file medium are called physical records.

 
  BUFFERS  
 

Modern computers are capable of handling I-O operations independent of the CPU by means of the hardware known as data channel. This enable the overlapping of I-O operations with other CPU operations. To take advantage of the situation, the IOCS normally requires more than one buffer for a file. For example, if two buffers are allocated for an input file, the IOCS can fill-in one buffer while the program process the records already read and available in another buffer.

 
  LABEL RECORDS/DISK DIRECTORY  
 

The blocks constituting a tape file is usually preceded and followed by records known as the header and trailer labels respectively. The header label normally contains information that helps the IOCS to identify the correct file. The most important of the information stored in the header label is what is known as the file title. Normally, tape files should be created with standard header and trailer labels.