Presentation is loading. Please wait.

Presentation is loading. Please wait.

File Handling in QBASIC

Similar presentations


Presentation on theme: "File Handling in QBASIC"— Presentation transcript:

1 File Handling in QBASIC
File handling is the process of writing records , reading records or editing records to/from an external data file. It an important aspect of programming. It this presentation you are going to learn :: Writing records to an external data file. Reading records data from an external data file. Updating records to an already created data file. Deleting records from an external data file. Lets Go…

2 Types of file mode used in QBASIC::
OUTPUT:- This mode is used to create a new data file and write the records in it. INPUT:- This mode is used to open an already existing data file and read the data from it. APPEND:- This mode is used to open an already existing data file and add records in it. Types of file: 1. Program file:- It the file in which you code the program and execute it 2. Data file:- It is the file in in which the records are stored

3 Some of the syntax used during file handling in QBASIC
Some of the syntax used during file handling in QBASIC. WRITE :- It is used to write the data to the data file. Syntax:- WRITE #1 , [variable1],[variable2],….[variableN] INPUT :- It is used to read the data from the data file. Syntax:- INPUT #1 , [variable1],[variable2],….[variableN]

4

5 Example 1. WAP to write the data name, class and roll number to an external file “std.txt” in which data are inputted by the user. Solution:: CLS OPEN “std.txt” FOR OUTPUT AS #1 INPUT “Enter name”;n$ INPUT “Enter class”;c INPUT “Enter roll”;r WRITE #1,n$,c,r END Explanation:- Here an external file “std.txt” is created by using OUTPUT mode whose file number is 1 and represented by #1. All the variables are asked to the user by using INPUT. WRITE helps to write the data to the file. Here data file is called by its file number and followed by the variables.


Download ppt "File Handling in QBASIC"

Similar presentations


Ads by Google