Questions tagged [qb64]

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 Vorbis
  • WAV

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

  1. Official Website at QB64.net for the program
  2. QB64.org, the Partner Site, maintained by community members actively contributing to the compiler codebase
  3. Official Wiki for information about all commands and functions.
  4. Official Forum for discussion about QB64
  5. 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
  • URLs and HTTP
  • 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

71 questions
5
votes
0 answers

Can I tell the QB64 compiler *not* to optimize my code?

I want to experiment with the efficiency of various algorithms and compiler optimization is an obstacle. Can I disable compiler optimizations in QB64?
Alex V
  • 3,416
  • 2
  • 33
  • 52
4
votes
1 answer

Can I take the entire console and save it as a string variable?

I'm trying to take the entire console text at the end of the program and save it as a string variable. Then after I will take the string variable and save it as a text document. What would be the best way to tackle this obstacle? Thank you!
4
votes
1 answer

Invalid variable name error in QB64 with old QuickBasic code

I am trying to run a QuickBasic file written by someone else in 1992. I am using QB64 on a Windows 10 machine. I get an error message that says Invalid variable name in line 26 of the following code. Lines 1-31 are below, but here is line 26 in…
Mark Miller
  • 12,483
  • 23
  • 78
  • 132
3
votes
4 answers

QB64 unable to load image, saying "illegal function call"

im trying to load an image for my game title instead of ASCII, but when i try to load the image, it says that _PUTIMAGE, i&. 0 is an illegal function call. Does _PUTIMAGE,i& not work for certain file types? I've tried all the ways the built-in help…
Patrick Coots
  • 301
  • 2
  • 10
3
votes
3 answers

Why don't INPUT$ and INKEY$ work in Linux console mode?

I written QB64 code to try the BASIC functions INPUT$ and INKEY$. This program runs good when it doesn't run in Linux console mode, but if we set the SW to run in Linux console mode this SW doesn't run correctly. It hangs. I think the issue is due…
Sir Jo Black
  • 2,024
  • 2
  • 15
  • 22
3
votes
2 answers

QB64 Console/Display Font Size

I am tutoring someone in my high school in QBasic and the QB64 font is really small making it difficult to edit it. How can I change the font?
Ryan Marvin
  • 47
  • 1
  • 7
3
votes
1 answer

QBasic: how to run a program from within another program?

I have made two different programs in QBasic and they both are saved in different .bas files, i.e one is 1.bas and the other 2.bas. How to open program 1.bas while I am in program 2.bas, without closing it? Program 1 should run inside program 2 for…
samrat luitel
  • 53
  • 1
  • 8
3
votes
4 answers

QBasic pass type as function argument

Went back to good old qbasic for nostalgic reasons and have never used types and functions in qbasic before as I was very young that time. TYPE Vector2 x AS SINGLE y AS SINGLE END TYPE FUNCTION Vector2Mag (a AS Vector2) Vector2Mag =…
Silberling
  • 160
  • 17
2
votes
1 answer

Main Menu made in QBasic (QB64)?

I've made this menu a long time ago, but I found the file about 2 days ago and I wanted to make it work CLS FOR k = 10 TO 65 LOCATE 2, k: PRINT CHR$(222) LOCATE 23, k: PRINT CHR$(222) LOCATE 4, k: PRINT CHR$(222) LOCATE 20, k: PRINT…
RaLe
  • 99
  • 9
2
votes
0 answers

How to Draw in a Qb64 console?

Let's say I am writing a code in QB64...To find the area of the quadrilaterals, and I want the output in a console. Thus, for more understanding, I wanted to draw a square like if I need to find the area of the square..but if I specify the string…
2
votes
0 answers

QB64 _MOUSEMOVEMENT not reading any input

I am using Ubuntu but am not very experienced with it yet, so this might be an Ubuntu problem instead of a QB64 problem, so I also posted it to askubuntu. Anyway, I wanted to make a program with mouse input, but although _MOUSEINPUT would return -1,…
2
votes
1 answer

Conflicting FIELD statements in QB64

When running this code it seems testfile.000 contains "00" and testfile.001 contains "99", so, why is there no conflict between these files?? Should it throw a "duplicate definition."? file1$ = "testfile.000" file2$ = "testfile.001" OPEN file1$ FOR…
eoredson
  • 1,167
  • 2
  • 14
  • 29
2
votes
3 answers

Loading bar or percentage possible while loading audio file in qb64

this is what i currently have PRINT "Loading..." soundHandle& = _SNDOPEN("Music.mp3") 'opens the sound file _SNDPLAYFILE "Music.mp3", , .25 'plays the sound file what I want it to do is a percentage to go up while it loads, if possible,
Patrick Coots
  • 301
  • 2
  • 10
2
votes
1 answer

Why is there a colon in some Programs between 2 statements

I was going through a QB64 tutorial and saw the following program structure for printing numbers from 1 to 10 → FOR x = 1 to 10: PRINT x: NEXT x I have never seen such a kind of QB64 program. What do those colons : mean? Are they anything…
Manu
  • 109
  • 5
2
votes
2 answers

How to set Title Bar Text and Application Icon

I want to make my QB64 program look professional, by setting a custom text in the Title Bar rather than the default (file name) and a custom Icon for the application file to be displayed in the Taskbar and Title Bar. I tried to use Resource Hacker…
Manu
  • 109
  • 5
1
2 3 4 5