Saturday, October 1, 2022

3.2 File processing (file handling)

 3.2 File processing (file handling)

 

Data file

The file which contains data given by the user to the program and information provided by the user to the computer is called data file.

The different types of data file are:

a)     Sequential Access files

b)     Random access files

 

Program File

The file which contains a set of instructions that are needed for data processing is called program file.

 

Mode of data file [SLC 2069]

Mode of data file means opening a sequential file for one of the three modes of operation like output mode, input mode and append mode.

 

Modes of operation for opening a sequential file

a)     Output Mode: It is used to create a new data file and write data in it. If the file already exists its current contents will be destroyed.

b)     Input Mode: It is used to retrieve records or contents of existing data file.

c)     Append Mode: It is used to add more records in existing file. If the specified file does not exist APPEND mode creates it.

File number

The number assigned to a file in order to identify it during processing is called file number.

 

Write down the functions of:

 

OPEN statement: It opens a sequential file for one of the three possible operations (reading, writing, appending).

 

WRITE statement [SEE 2075] [MM 2076]: It sends one or more data items to the specified file. It inserts commas between the data items. It encloses strings in double quotation marks.

 

PRINT#: It adds spaces between data items while storing data. It does not enclose strings in double quotation marks.

 

CLOSE statement [SEE 2074] [SEE 2073: It closes one or all open files.

 

INPUT# statement: It reads data from the sequential data file.

 

EOF( ) function [SEE 2075 S 2]: It is used to test the end of records with in a file.

 

LINE INPUT statement: It reads the entire line or maximum 255 characters form the keyboard or the sequential file.

 

INPUT$ function: It reads the specified number of characters form the data file.

 

NAME statement [SEE 2073] [SLC 2071 S]: The NAME statement renames a file on a diskette. Only file name changes, data and program line remains intact.

KILL statement [SEE 2074]: The KILL statement deletes the file or files from the specified drive and directory.

 

MKDIR statement [SEE 2075 U]: It creates a subdirectory which is used to manage files.

 

CHDIR statement: It allows QBASIC to change from one directory to another.

 

RMDIR statement [SLC 2065] [SLC 2068 S]: It is used to remove or delete only the subdirectories from a disk. It can remove only empty subdirectories.

 

FILES statement: The FILES statement displays the files of the current sub directory or specified sub directory.

SHELL: The SHELL statement allows a program to run external programs or command line statements in Windows, MAC OS and Linux.

INT [MM 2076] [MFT 2075]: It rounds and returns the largest integer less than or equal to a numeric expression.

PRINT [PMT 2075K] : Display result on screen.

MID$ ( ) [MFT 2075]: It is a string function that returns the specified number of characters from the specified location of string.

LEN ( ) [SQE 2074K]: Returns the number of characters in a string or the number of bytes required to store a variable.

SQR ( ) [SQE 2074K]: Returns the square root of a numeric expression.

No comments:

Post a Comment