QB64

Last updated
QB64
QB64-1-4-logo-hd-transparency.svg
Developer Rob Galleon, QB64Team
First appearedSeptember 8, 2007;16 years ago (2007-09-08)
Stable release
2.0.2 / November 7, 2021;22 months ago (2021-11-07)
OS Microsoft Windows, Linux, macOS
License MIT
Website www.qb64.com
Influenced by
QuickBASIC, QBASIC

QB64 (originally QB32) [1] is a self-hosting BASIC compiler for Microsoft Windows, Linux and Mac OS X, designed to be compatible with Microsoft QBasic and QuickBASIC. QB64 is a transpiler to C++, which is integrated with a C++ compiler to provide compilation via C++ code and GCC optimization. [2]

Contents

QB64 implements most QBasic statements, and can run many QBasic programs, including Microsoft's QBasic Gorillas and Nibbles games. [3] Furthermore, QB64 has been designed to contain an IDE resembling the QBASIC IDE. QB64 also extends the QBASIC programming language to include 64-bit data types, as well as better sound and graphics support. It can also emulate some DOS/x86 specific features such as INT 33h mouse access, and multiple timers.

Since version 2.0, QB64 now offers debugging abilities, with the new $DEBUG metacommand. [4]

History

QB64 was originally compiled with QuickBASIC 4.5. After significant development, Rob 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. [5] After version 0.63, QB64 was able to compile itself so the conventional memory limitations no longer applied.

Regarding the impetus for QB64, Galleon said: [6]

I began to see the need for QB64 when it was clear that the introduction of VISTA would cripple QBASIC, relegating it to an ancient language only runnable on emulators which allow little/no chance of taking advantage of modern features on computers. The actual coding of QB64 began at the beginning of this year and QB64 has made steady progress since. I have had experience writing programming languages before so I knew in advance the challenges that awaited.

Starting in 2016, work began on a graphical user interface builder and event driven integrated development environment called InForm, giving features similar to Visual Basic. [7]

Syntax

QB64's syntax is designed to be completely backwards compatible with QuickBASIC. Line numbers are not required, and statements are terminated by newlines or separated by colons (:).

An example "Hello, World!" program is:

PRINT"Hello, World!"

An example of QB64's emulation of VGA memory for compatibility:

CLSS$="Hello, World!"DEF SEG=&HB800'sets the segment to video memoryFORI=1TOLEN(S$)POKE160+(I-1)*2,ASC(MID$(S$,I,1))'characterNEXTDEF SEG'reset the segment to default

An example of how QB64 allows audio files:

sound_effect&=_SNDOPEN("sound.wav")'WAV, OGG or MP3_SNDPLAYsound_effect&

An example of how QB64 allows picture files:

SCREEN_NEWIMAGE(800,600,32)'creates a 32-bit screenimagename&=_LOADIMAGE("image__name.png")'BMP, JPG, PNG, etc._PUTIMAGE(0,0),imagename&_FREEIMAGEimagename&'release assigned memory

An example of how QB64 uses multiple timers:

t1=_FREETIMERt2=_FREETIMERON TIMER(t1,1)GOSUBTimer.Trap'the code following the Timer.Trap label will be run every 1 secondON TIMER(t2,.5)mySub'QB64 can also trigger a SUB procedure with TIMER;'                       in this case mySUB will be triggered every 500 milliseconds'activate timers:TIMER(t1)ONTIMER(t2)ONDO'go into an infinite loop until the window is closed_LIMIT1'run the main loop at 1 cycle per second, to show how timers are independent from main program flowLOOPTimer.Trap:PRINT"1s; ";RETURNSUBmySubPRINT"500ms; ";ENDSUB

Extensions to QBASIC

QB64's extended commands begin with an underscore in order to avoid conflicts with any names that may be used in a QuickBASIC program. Beginning with version 1.4, the underscore prefix can be dropped by using the metacommand $NOPREFIX. [8] QB64 extends the QuickBASIC language in several ways. It adds the new data types including _BIT, _BYTE, _INTEGER64 and _FLOAT as well as 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 Vorbis, and WAV files as well as libraries allowing users to use higher resolution graphics than the 640×480 offered by QuickBASIC, [9] use different fonts, and plot images in BMP, PNG, and JPEG formats. It also allows the use of 32-bit colors as opposed to the limited 256 (or 16, depending) 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.

Another significant feature that has been added is networking. Initially this allowed the opening of a TCP/IP stream that could be read and written using Input#/Print# instructions. This mode has its own proprietary packet encapsulation format which, whilst being easy to use with QBasic, meant that it could only be used to communicate with other QB64 programs or server backends with custom interfaces created specifically for the application. Later versions add GET# and PUT# to read and write raw bytes from the stream. This allows native implementations of standard protocols such as smtp and http.

Advantages of QB64

Libraries

QB64 integrates FreeGLUT for its graphics and text.

A development branch of the repository hosted on GitHub is frequently updated with fixes and improvements, which will eventually become the next stable release. The development builds are also offered via the official website for users to beta test.

QB64 can also use DLL libraries for Windows and C++ headers with a DECLARE LIBRARY block. Users can also access C header files to run C functions.

Forks

Due to a shakeup in the community in 2022, there are now at least two forks of the QB64 project. [10] The "QB64 Team" Github repository is no longer active, and all new development is being done in new forks:

Related Research Articles

<span class="mw-page-title-main">BASIC</span> Family of programming languages

BASIC is a family of general-purpose, high-level programming languages designed for ease of use. The original version was created by John G. Kemeny and Thomas E. Kurtz at Dartmouth College in 1963. They wanted to enable students in non-scientific fields to use computers. At the time, nearly all computers required writing custom software, which only scientists and mathematicians tended to learn.

<span class="mw-page-title-main">GW-BASIC</span> Dialect of the BASIC programming language

GW-BASIC is a dialect of the BASIC programming language developed by Microsoft from IBM BASICA. Functionally identical to BASICA, its BASIC interpreter is a fully self-contained executable and does not need the Cassette BASIC ROM found in the original IBM PC. It was bundled with MS-DOS operating systems on IBM PC compatibles by Microsoft.

<span class="mw-page-title-main">PNG</span> Family of lossless compression file formats for image files

Portable Network Graphics is a raster-graphics file format that supports lossless data compression. PNG was developed as an improved, non-patented replacement for Graphics Interchange Format (GIF)—unofficially, the initials PNG stood for the recursive acronym "PNG's not GIF".

<span class="mw-page-title-main">Allegro (software library)</span> Software library for video game development

Allegro is a software library for video game development. The functionality of the library includes support for basic 2D graphics, image manipulation, text output, audio output, MIDI music, input and timers, as well as additional routines for fixed-point and floating-point matrix arithmetic, Unicode strings, file system access, file manipulation, data files, and 3D graphics. The library is written in the C programming language and designed to be used with C, C++, or Objective-C, with bindings available for Python, Lua, Scheme, D, Go, and other languages. Allegro comes with extensive documentation and many examples.

<span class="mw-page-title-main">QuickBASIC</span> IDE for the BASIC programming language

Microsoft QuickBASIC is an Integrated Development Environment and compiler for the BASIC programming language that was developed by Microsoft. QuickBASIC runs mainly on DOS, though there was also a short-lived version for the classic Mac OS. It is loosely based on GW-BASIC but adds user-defined types, improved programming structures, better graphics and disk support and a compiler in addition to the interpreter. Microsoft marketed QuickBASIC as the introductory level for their BASIC Professional Development System. Microsoft marketed two other similar IDEs for C and Pascal, viz QuickC and QuickPascal.

Microsoft BASIC is the foundation software product of the Microsoft company and evolved into a line of BASIC interpreters and compiler(s) adapted for many different microcomputers. It first appeared in 1975 as Altair BASIC, which was the first version of BASIC published by Microsoft as well as the first high-level programming language available for the Altair 8800 microcomputer.

<span class="mw-page-title-main">Visual Basic (.NET)</span> Object-oriented computer programming language

Visual Basic (VB), originally called Visual Basic .NET (VB.NET), is a multi-paradigm, object-oriented programming language, implemented on .NET, Mono, and the .NET Framework. Microsoft launched VB.NET in 2002 as the successor to its original Visual Basic language, the last version of which was Visual Basic 6.0. Although the ".NET" portion of the name was dropped in 2005, this article uses "Visual Basic [.NET]" to refer to all Visual Basic languages released since 2002, in order to distinguish between them and the classic Visual Basic. Along with C# and F#, it is one of the three main languages targeting the .NET ecosystem. Microsoft updated its VB language strategy on 6 February 2023, stating that VB is a stable language now and Microsoft will keep maintaining it.

<span class="mw-page-title-main">Gambas</span> Integrated development environment

Gambas is the name of an object-oriented dialect of the BASIC programming language, as well as the integrated development environment that accompanies it. Designed to run on Linux and other Unix-like computer operating systems, its name is a recursive acronym for Gambas Almost Means Basic. Gambas is also the word for prawns in the Spanish, French, and Portuguese languages, from which the project's logos are derived.

<span class="mw-page-title-main">SmallBASIC</span> BASIC programming language dialect with interpreters released as free software

SmallBASIC is a BASIC programming language dialect with interpreters released as free software under the GNU General Public License version 3 for Microsoft Windows, Linux and Android.

A FourCC is a sequence of four bytes used to uniquely identify data formats. It originated from the OSType or ResType metadata system used in classic Mac OS and was adopted for the Amiga/Electronic Arts Interchange File Format and derivatives. The idea was later reused to identify compressed data types in QuickTime and DirectShow.

<span class="mw-page-title-main">FreeBASIC</span> BASIC dialect

FreeBASIC is a free and open source multiplatform compiler and programming language based on BASIC licensed under the GNU GPL for Microsoft Windows, protected-mode MS-DOS, Linux, FreeBSD and Xbox. The Xbox version is no longer maintained.

A container format or metafile is a file format that allows multiple data streams to be embedded into a single file, usually along with metadata for identifying and further detailing those streams. Notable examples of container formats include archive files and formats used for multimedia playback. Among the earliest cross-platform container formats were Distinguished Encoding Rules and the 1985 Interchange File Format.

<span class="mw-page-title-main">Visual Basic (classic)</span> Event-driven programming language

The original Visual Basic is a third-generation event-driven programming language from Microsoft known for its Component Object Model (COM) programming model first released in 1991 and declared legacy during 2008. Microsoft intended Visual Basic to be relatively easy to learn and use. Visual Basic was derived from BASIC and enables the rapid application development (RAD) of graphical user interface (GUI) applications, access to databases using Data Access Objects, Remote Data Objects, or ActiveX Data Objects, and creation of ActiveX controls and objects.

BSAVE and BLOAD are commands in many varieties of the BASIC programming language. BSAVE copies RAM to a binary file, and BLOAD copies the contents of the file to RAM. The term "BSAVE image" could mean any of various raw image formats of video display controllers, or more generally any file containing the raw contents of a section of memory.

Music Macro Language (MML) is a music description language used in sequencing music on computer and video game systems.

<span class="mw-page-title-main">MSWLogo</span> Programming language

MSWLogo is a programming language which is interpreted, based on the computer language Logo, with a graphical user interface (GUI) front end. It was developed by George Mills at the Massachusetts Institute of Technology (MIT). Its core is the same as UCBLogo by Brian Harvey. It is free and open-source software, with source code available, in Borland C++.

<span class="mw-page-title-main">QBasic</span> IDE for the BASIC programming language

QBasic is an integrated development environment (IDE) and interpreter for a variety of dialects of BASIC which are based on QuickBASIC. Code entered into the IDE is compiled to an intermediate representation (IR), and this IR is immediately executed on demand within the IDE.

The IBM Personal Computer Basic, commonly shortened to IBM BASIC, is a programming language first released by IBM with the IBM Personal Computer, Model 5150 in 1981. IBM released four different versions of the Microsoft BASIC interpreter, licensed from Microsoft for the PC and PCjr. They are known as Cassette BASIC, Disk BASIC, Advanced BASIC (BASICA), and Cartridge BASIC. Versions of Disk BASIC and Advanced BASIC were included with IBM PC DOS up to PC DOS 4. In addition to the features of an ANSI standard BASIC, the IBM versions offered support for the graphics and sound hardware of the IBM PC line. Source code could be typed in with a full-screen editor, and very limited facilities were provided for rudimentary program debugging. IBM also released a version of the Microsoft BASIC compiler for the PC, concurrently with the release of PC DOS 1.10 in 1982.

References

  1. Stephane Richard (2007-11-16). "In The News". PCOPY! Issue #50. Basic Programming. Archived from the original on 2009-12-21. Retrieved 2008-08-17.
  2. E.K.Virtanen (2008-05-26). "Interview With Galleon". PCOPY! Issue #70. Basic Programming. Archived from the original on 2008-08-21. Retrieved 2008-07-14.
  3. "QB64 Screenshots - QB64/QBASIC Gorillas in QB64". Archived from the original on 2013-05-12. Retrieved 2010-07-27.
  4. "Changelog for v2.0 – QB64.org". www.qb64.org. Archived from the original on 2021-10-10.
  5. "More BUGS please! (Seriously)". 3 March 2008.
  6. "Welcome to the QB64 Forum!". THE QBASIC FORUM. 30 September 2007. Retrieved 2020-01-28.
  7. Rogoz, Ivan (2022-04-07). "Blast from the past - QBasic 4.5". Barn Lab. Retrieved 2023-09-26. QB64 comes with a WYSIWYG IDE editor called InForm which brings it closer to everyday use as a quick and dirty language for automation for Windows.
  8. "Changelog for v1.4 – QB64.org". www.qb64.org. Archived from the original on 2020-02-13.
  9. "QB Advisor: Screen Modes 11, 12, and 13". Microsoft Corporation. 1988. Archived from the original on 2009-01-05. Retrieved 2008-07-25.
  10. Proven, Liam (2023-03-28). "Nostalgic for VB? BASIC is anything but dead". The Register . Retrieved 2023-10-01. So does QB64, although the dust has yet to completely settle over a split among its developers. A community called QB64 Phoenix is actively developing a new Phoenix Edition.