World Library  
Flag as Inappropriate
Email this Article


Article Id: WHEBN0023712097
Reproduction Date:

Title: QBasic  
Author: World Heritage Encyclopedia
Language: English
Subject: PowerBASIC, BASIC, Basic4android, True BASIC, GW-BASIC
Publisher: World Heritage Encyclopedia


Paradigm(s) Procedural
Developer Microsoft
Appeared in 1991 (1991)
Influenced by QuickBASIC, GW-BASIC
Influenced QB64
OS MS-DOS, Windows 95, Windows 98, Windows Me, PC DOS, OS/2, eComStation
License Part of the operating system (a variety of closed-source licenses)
Website .com.microsoftwww

QBasic (Microsoft Quick Beginners All purpose Symbolic Instruction Code) is an IDE and interpreter for a variant of the BASIC programming language which is based on QuickBASIC. Code entered into the IDE is compiled to an intermediate form, and this intermediate form is immediately interpreted on demand within the IDE.[1] It can run under nearly all versions of DOS and Windows, or through DOSBox/DOSEMU, on Linux and FreeBSD.[2] For its time, QBasic provided a state-of-the-art IDE, including a debugger with features such as on-the-fly expression evaluation and code modification.

Like QuickBASIC, but unlike earlier versions of Microsoft BASIC, QBasic is a structured programming language, supporting constructs such as subroutines and while loops.[3][4] Line numbers, a concept often associated with BASIC, are supported for compatibility, but are not considered good form, having been replaced by descriptive line labels.[1] QBasic has limited support for user-defined data types (structures), and several primitive types used to contain strings of text or numeric data.[5][6]


QBasic was intended as a replacement for GW-BASIC. It was based on the earlier QuickBASIC 4.5 compiler but without QuickBASIC's compiler and linker elements. Version 1.0 was shipped together with MS-DOS 5.0 and higher, as well as Windows 95, Windows NT 3.x, and Windows NT 4.0. IBM recompiled QBasic and included it in PC DOS 5.x, as well as OS/2 2.0 onwards.[7] eComStation, descended from OS/2 code, includes QBasic 1.0. QBasic 1.1 is included with MS-DOS 6.x, and, without EDIT, in Windows 95, Windows 98 and Windows Me. Starting with Windows 2000, Microsoft no longer includes QBasic with their operating systems.[8] However, some localized versions of Windows 2000 and Windows XP still have it, and it can be given out as freeware.

QBasic (as well as the built-in MS-DOS Editor) is backward compatible with DOS releases prior to 5.0 (down to at least DOS 3.20). However, if used on any 8088/8086 computers, or on some 80286 computers, the QBasic program may run very slowly, or perhaps not at all, due to DOS memory size limits. Until MS-DOS 7, MS-DOS Editor required QBasic: the EDIT.COM program simply started QBasic in editor mode only, and this mode can also be entered by running QBASIC.EXE with the /EDITOR switch (i.e., command line QBASIC /EDITOR).


QBasic came complete with four pre-written example programs. These were "Nibbles", a variant of the Snake game; "Gorillas", an Artillery game; "MONEY MANAGER", a personal finance manager; and "RemLine", a GW-BASIC code line-number-removing program.[1]

"Hello, World!"

PRINT "Hello, World!"

Simple game

This program challenges the user to guess a randomly selected number within the 1-10 range, without offering the usual hints of "higher"/"lower":

PRINT "Guess the number!"
INPUT "Would you like to play? (Y/N): ", choice$     ' An input statement, that takes what the user inputs...
IF LEFT$(LCASE$(choice$),1) = "y" THEN                      ' and decides whether or not you want to play:
  guesses% = 5                                       ' Set up number of guess remaining
  RANDOMIZE TIMER                                    ' Sets up the random number generator
  target% = INT(RND * 10) + 1                        ' Picks a random number between 1 and 10 (inclusive)
  won% = 0                                           ' Sets up a flag called 'won%' to check if user has won
  PRINT "The number is between 1 and 10."
  WHILE guesses% > 0 AND won% = 0                    ' Enters a loop until the user wins or runs out of chances
    INPUT "Enter your guess: ", guess%               ' Takes user input (the guess)
    IF guess% = target% THEN                         ' Determines if the guess was correct
      PRINT "Correct, the answer was "; target%; "!"
      won% = 1                                       ' Sets a flag to indicate user has won
      guesses% = guesses% - 1                        ' Deducts one chance
      PRINT "Sorry, please try again. You have "; guesses%; " guesses left."
    END IF
  WEND                                               ' End of guessing loop
  IF won% = 0 THEN PRINT "You ran out of guesses, the number was "; target%; "."

Easter egg

QBasic has a little-known Easter egg. To see it, press and hold:
Left CTRL+Left SHIFT+Left ALT and Right CTRL+Right SHIFT+Right ALT simultaneously after running QBasic at the DOS prompt but before the title screen loads: this lists The Team of programmers.[9] Note that on fast modern computers, it is impossible to perform. It is best done on an old PC (preferably one with a working Turbo button, with the switch on to slow the CPU to 4.77 MHz) or in an emulator like Bochs or DOSBox which can be slowed down.

See also


  1. ^ a b c "Differences Between GW-BASIC and QBasic". 2003-05-12. Retrieved 2008-06-28. 
  2. ^ "HOWTO Play With Your Old QBasic Programs on Linux". 2007-03-31. Retrieved 2008-06-28. 
  3. ^ "QBASIC Manual: SUB...END SUB Statement QuickSCREEN". Retrieved 2008-06-28. 
  4. ^ "QBASIC Manual: WHILE...WEND Statement QuickSCREEN". Retrieved 2008-06-28. 
  5. ^ "QBASIC Manual: TYPE Statement QuickSCREEN". Retrieved 2008-06-28. 
  6. ^ "QBASIC Manual: Limits - Names, Strings, and Numbers". Retrieved 2008-06-28. 
  7. ^ "Microsoft BASIC version information". Retrieved 2008-06-12. 
  8. ^ "QBasic Missing from Windows 2000". 2007-03-01. Retrieved 2008-06-12. 
  9. ^ "QBasic - Developer Credits". 1999-07-23. Retrieved 2008-06-12. 

External links

  • Download QBASIC 1.1 from the Internet Archive (included in the "Old MS-DOS Utilities" part of Windows 95 CD-ROM Extras)
  • QB Express — Online magazine about QBasic programming
  • The QBasic Station — Created in 1997 by Jack Thomson, it was one of the oldest QBasic sites on the web.
  • qb.js: An implementation of QBASIC in Javascript — Allows to run QBasic subset (lacks optional legacy syntax with line numbers, LET, etc.) programs online
  • QB64 a 64bit compiler implementing the QBasic language with some 64-bit extensions. Windows XP or newer, Mac OS X with Xcode and Xquartz & Linux.
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.

Copyright © World Library Foundation. All rights reserved. eBooks from Project Gutenberg are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.