CSC001- Getting Started with QBASIC

ublkline620.GIF (83 bytes)

D. Joseph
Fall 1998

Creating a Program | The QBASIC Screen | Saving a Program | Running a Program | The Output Screen
Opening a Program File  | Exiting from QBASIC

 

Creating a Program Using the QBASIC Editor

The directions for accessing QBASIC are for Windows 95/98/NT.

  1. Click the Start button to display the Start menu.
  2. Point to Programs.
  3. Choose MS-DOS Prompt and an MS-DOS Prompt window opens.

    doswin.gif (5468 bytes)

  4. At the C:\> prompt (or at the C:\Windows> prompt), type QBASIC and press the ENTER key and the QBASIC editor appears.

    qbasic1.gif (7940 bytes)


  5. Press the ESC key to clear the dialog (Welcome) box.
  6. Start typing your program.

 

About the QBASIC Screen

qbasic2.gif (4962 bytes)

  • The menu bar is located acrosss the top of the window and it shows you a list of menu names like File, Edit, Search, Run, Debug, and Options. When one of the menus is opened, a pull-down list of commands appears.
  • The view window is the largest part of the QBASIC screen. This is where you type your program. At the top of the window is the title line that displays the name of the program file you are editing. The program file name is Untitled until you give it a name (by saving the program file).
  • Along the right side of the window and across the bottom are the scroll bars. By clicking the mouse in the scroll bars, you can move around your program to see other areas.
  • The cursor (or insertion point) is the blinking rectangle that lets you know your current position within the program.
  • The immediate window is located just below the view window and it's used to execute statements as soon as they are entered. This window is often used as a calculator and a debugging tool. You can activate this window by pressing the F6 key and you can return to the view window by pressing the F6 key again.
  • The status line is located across the very bottom of the window and it displays a list of the most frequently used function keys. It will also indicate whether you have the CAPS LOCK key on.

 

Saving a Program to Your Floppy Disk

  1. Make sure that your disk is in floppy drive, A:
  2. Open the File menu.
  3. Select the Save As command and the Save As dialog box appears.

    saveas.gif (3245 bytes)
  4. In the File Name box, type A: followed by the name of the file. (For example, suppose you are working on Lab Chapter 3, Exercise 1, you might type A:LAB3EX1.)

    Triangbk.gif (69 bytes) Special Rules for Naming Files when using MS-DOS:

    - The program file name must consist of one (1) to eight (8) characters.
    - The characters may be letters of the alphabet, digits, or special characters like $ # & @ ! % ( ) - { } ' ~ ^ _
    - No blank spaces are allowed in the name.

    Triangbk.gif (69 bytes) Once you have saved your program there are two copies:
    - one copy in RAM (memory)
    - one copy on the disk

    Triangbk.gif (69 bytes) When you make changes to your program, the changes are made only to the copy in RAM (memory).

    Triangbk.gif (69 bytes) To preserve the changes to the copy on the disk, you must save the program again.

 

Running a Program

  1. Open the Run menu.
  2. Select the Start command.

    run.gif (1754 bytes)

Note:

  • When you run a program, you are telling the computer to carry out (or execute) the list of instructions in the program.
  • Output is what carrying out the list of instructions in the program produces.
  • If your program does not work, you may get a message about an error.
  • If the program works, the output screen will appear and display the results of processing the instructions.

 

Leaving the Output Screen

  • When you are finished viewing the output, press the F4 key to return to the view window that contains your program.
  • Anytime you want to view the output, press the F4 key to return to the output screen.

 

Opening a Program File from Your Floppy Disk

Here's the scenario...You started typing a program last Friday and you were unable to finish it, so you saved it to your floppy disk. Today, you want to finish typing the program. In order to complete the program, you must open the program file from your floppy disk.

  1. Start QBASIC if you haven't already done so.
  2. Make sure your disk is in floppy drive A:
  3. Open the File menu.
  4. Select the Open command and the Open dialog box appears.

    open.gif (3967 bytes)

  5. Type A:*.BAS and press the ENTER key.
    The contents of the disk in drive A are shown in the Open dialog box.
  6. Locate and select your program file.
  7. Now you can complete your program or make corrections to it.

 

Exiting from QBASIC and the MS-DOS Window

  1. In the QBASIC window, open the File menu.
  2. Choose the Exit command and the DOS (C:\> or C:\Windows>) prompt appears.
  3. Type exit and press the ENTER key.
    The window closes and you are brought back to the Windows 95/98/NT desktop.

 

ublkline620.GIF (83 bytes)

Return to:  CSUS | Computer Science

September 11, 1998
Comments to:  josephd@csus.edu