QBASIC is a high level programming language that allows us to write programs. BASIC uses English like words and mathematical symbols to write programs. The programs written in QBASIC need to be converted into machine codes. QBASIC provides working area to write programs and QBASIC has its own Interpreter. QBASIC converts one statement of a program into machine code at a time. After the execution of the previous statement, it converts another statement of the program into machine code and so on. For this reason, QBASIC is also called an Interpreter.
QBASIC Editor checks syntax errors and capitalizes QBASIC reversed words. QBASIC Editor provides all the facilities that are required for programs. In the QBASIC Editor; you can write, edit, run and debug programs.
FEATURE OF QBASIC
Some features of QBASIC are listed below:
- does not use technical terminology (word) to write statements.
- automatically checks syntax.
- capitalizes the reserved words.
- keeps the same variable name used in a program to identical form.
- allows you to break lengthy programs into modules.
- interprets a statement of a program at a time to CPU.
QBASIC programming language consists of two files: QBASIC.EXE and QBASIC.HLP. Normally these files are found in a folder named ‘QBASIC’ which is in drive C:.
To start Q BASIC, follow these steps.
Click the Start button.
Point to All Programs and then Accessories.
Select Command Prompt. It displays Command Prompt Window.
To move to the root directory, at DOS prompt, type CD\ and press Enter key.
At C:\> prompt, type CD QBASIC and press Enter key.
At C:\ QBASIC> prompt, type qbasic and press Enter key. It will display QBASIC Welcome Screen.
Press Esc key to get QBASIC Editor Screen.
QBASIC EDITOR SCREEN
Editor is the window where you write programs. The editor provides all the facilities to write programs and editing them.
Editor Screen has four parts.
- Menu Bar.
- Program Window
- Immediate Window
- Status Bar
- Menu Bar
The Menu Bar consists of list of commands like File, View, Search, Run, Debug, Options and Help. These menus again have some sub commands such as FILE= New, Open, Save, Save As, Print, Exit. EDIT= Cut, Copy, Paste, Clear, New Sub, New Function. VIEW= Subs, Spilt, Output Screen. SEARCH= Find, Repeat Last Find, Change. RUN= Start, Restart, Continue. DEBUG= Step, Procedure Step, Trace On, Toggle Breakpoint, Clear All Breakpoints breakpoints, Set Next Statement. OPTIONS= Display, Help Path, Syntax Checking.
- Program Window
The upper window which is titled as ‘Untitled’ is the window where you write programs. This window is called Program Window. To see the output of the statements written in this window, you need to press Shift + F5 key.
- Immediate Window
The lower window which is titled as ‘Immediate’ is known as Immediate Window where you test commands, expressions etc. As soon as you press Enter key, it displays the output on the screen.
Note: F6 function key is used to switch from Program Window to Immediate Window and vice versa.
- Status Bar
The status bar shows short cut keys and the location of the cursor on the screen.
RUNNING A PROGRAM
After entering a set of instructions in the Program Window, you may want to see the output of the program. To see the output of the program you need to run a program. When you run a program IT converts and directs each statement of a program at a time to the CPU. To run (execute) a program
Press Shift + F5 key or press Alt, R, S.
F5 key is used for continuing the program from the previous stop statement.
SAVING A PROGRAM
You need to save a program for the future use. Sometimes you need to save incomplete program so that you can complete at next time. To save a program, follow these steps:
Press ALT + F key.
Highlight Save As Option.
Press Enter key. It displays Save Dialog Box.
Enter Filename in the Filename text box.
Press Enter key.
When you supply filename just use not more than eight characters for filename.
Program automatically adds an extension as .BAS for the program file.
CLEARING PROGRAM WINDOW
To write a new program you need to remove the previous program from the Program Window. To clear or remove the previous program, follow these steps.
- a) Press ALT key.
- b) Highlight New option and press Enter key. OR. Press F, N keys.
OPENING AN EXISTING PROGRAM
To open an existing program in the Program Window, follow these steps.
- Press Alt key.
- Press F key.
- Highlight Open command and press Enter key.
- Select a program file the list of files displayed in the Open Dialog box and press Enter key
To exit from the Program, follow these steps.
- Press ALT key. It will activate menu.
- Press F or Enter key.
- Press X or select Exit command under File menu and press Enter key.