Freeware QuickBasic 4.5 compiler
Overview
QB64 is a modern version of the Basic programming language, and a freeware self-hosting compiler that allows programs created using Quick Basic 4.5 or Qbasic to run on Windows XP, Vista, 7, 8, 8.1 and 10, Linux and Mac OSX.
QB64 is a C++ emitter, which is integrated with a C++ compiler to provide compilation via C++ code and GCC optimization.
Basic Information
Developer - Galleon, QB64 Team
Released - 2007
License - LGPLv2.1
Similarity to QBasic and QuickBasic
QB64 can compile and run all programs written in QBasic or QuickBasic, as its syntax is designed to be completely backwards compatible with QuickBASIC.
It implements most QBasic statements, and can run many QBasic programs, including Microsoft's QBasic Gorillas and Nibbles games. Furthermore, QB64 has been designed to contain an IDE resembling the QBASIC IDE.
It can also emulate some DOS/x86
specific features such as INT
33h mouse access, SHELL
and timers.
Extensions to QBasic and QuickBasic
QB64 works on 32 or 64 bit machines and can compile applications for Windows, Linux, MacOS X and even Android. It has many new features such as
- stereo sound
- improved graphics
- TCP/IP internet capabilities.
QB64's extended commands begin with an underscore (_
) in order to avoid conflicts with any names that may be used in a QuickBASIC program.
QB64 extends the QuickBASIC language include 64-bit
data types. It adds the new data types including
_BIT
_BYTE
_INTEGER64
_FLOAT
- Unsigned data types.
The new data types have suffixes just like the traditional BASIC data types.
QB64 also includes an audio library which allows playing most common audio formats including
MP3
OGG
VorbisWAV
It also has libraries allowing users to
- use higher resolution graphics than the
640 × 480
offered by QuickBASIC - use different fonts
- plot images in the following formats:
BMP
PNG
JPEG
It also allows the use of 32-bit
colors as opposed to the limited 256
(or 16
) colors originally offered.
The programmer also does not have to specify which programming libraries to include since QB64 does it automatically. The programmer has the option to include a library of their own through the $INCLUDE
command just as QuickBASIC did.
Syntax
A basic Hello World program:
PRINT "Hello World!"
Line numbers don't need to be written. Statements are terminated by newlines or by colons (:
).
An example of QB64's emulation of VGA
memory for compatibility:
CLS
S$ = "Hello, World!"
DEF SEG = &HB800 'sets the segment to video memory
FOR J = 1 TO 15
FOR I = 1 TO LEN(S$)
POKE J * 160 + (I - 1) * 2, ASC(MID$(S$, I, 1))'character
POKE J * 160 + (I - 1) * 2 + 1, (J + 128)
NEXT
NEXT
An example of how QB64 allows picture and audio files:
sound_effect& = _SNDOPEN("sound.wav")
_SNDPLAY sound_effect&
imagename& = _LOADIMAGE("image__name.png")
In QB64, comments are given with a single quote ('
) at the beginning
PRINT "Something!" 'This is a comment
'Comments can be put anywhere
Double Quotes ("
) are used in strings, and cannot be escaped. In order put a double quote inside a string, you must print the ASCII character.
PRINT "Mark said, "I am fine!""
This will produce an error since it will be parsed as
1st String | "Mark said,"
Variable (INTEGER)| I
Variable (INTEGER)| am
Variable (SINGLE) | fine!
2nd String | ""
But since the strings and variables are not concatenated with a semi-colon, an error will be thrown. Instead, you should do this:
PRINT "Mark said, "; CHR$(34); "I am fine!"; CHR$(34)
This will be parsed as
1st String | "Mark said, "
T;
ASCII Character 34 | "
;
2nd String | "I am fine!"
;
ASCII Character 34 | "
This will thus output to
Mark said, "I am fine!"
However, it isn't wrong to put single quotes within strings normally, as in
PRINT "Let's Go and ride John's bicycle"
Will output to
Let's Go and ride John's bicycle
History
QB64 was originally compiled with QuickBASIC 4.5. After significant development, Galleon, the developer, became hindered by QuickBASIC's memory limitations and switched to Microsoft Basic PDS 7.1, which solved these problems for a short time.
After version 0.63, QB64 was able to compile itself so the Conventional memory limitations no longer applied.
All information about different versions, and comparisons can be viewed at QB64.net/Wiki. Different historical versions of QB64 can be downloaded at QB64.org.
Libraries
As of version 0.954
, the SDL
version of QB64 has been discontinued. The current (and future) versions of QB64 integrate FreeGLUT
for its graphics and text.
Daily builds are generated with additions and fixes to the code base, hosted on GitHub.
QB64 can also use DLL
libraries for Windows, C++ and SDL
functions and statements with a DECLARE LIBRARY
block. Users can also access C header files to run C functions.
A list of useful QBasic Libraries can be viewed at Pete's QB.
Source Code
QB64 is open sourced and the source can be seen at GitHub. Many users constantly build their own versions of QB64 with buf fixes, etc., which are called Daily Builds. Daily builds can be viewed at the official site.
Resources
- Official Website at QB64.net for the program
- QB64.org, the Partner Site, maintained by community members actively contributing to the compiler codebase
- Official Wiki for information about all commands and functions.
- Official Forum for discussion about QB64
- The GitHub Repository
Questions
Questions asked within the [QB64]
Tag must be within the scope and capacity of this Language/Compiler. They may be related to
- Build and Compile
- Execution
- File Handling
URL
s andHTTP
- Debugging code written to achieve the above
Questions seeking Debugging help must provide a piece of code in QB64. If the code contains no commands that were extended in QB64 from QBasic, then a link to the code at Repl.it Online QBasic Compiler may also be given. The question may also be tagged with the [QBasic]
or [QuickBasic]
tags if the program is compatible with them.
Chat Room
Join the discussion at this Stack Overflow Chatroom