Frequently Asked Questions

In this list the following questions will be answered:

How To Make An EXE-File?

To convert your BASIC program into an EXE-file that will run without the need of another program, you need a
compiler. There are several available, commercial and shareware (which is also commercial, but shareware compilers are mostly less expensive and have the advantage of Try Before You Buy). Usually a compiler has more features than a interpreter. These could include the possibility of making TSR's and incorporating assembler code into the BASIC program.

How To Do Mouse Support?

For this, calls to the mouse driver have to be made. Click
here to see an example of how you can shape your own mouse cursor in text mode, and how to make buttons on the screen work. The author is Wouter Bergmann Tiest.

How To Read A Directory From Disk?

To to this, it is nescessary to call BIOS interrupts.
This shows you how to do that. It is a collection of file routines by someone named Tomppa. It was contributed by Utriainen Tommi.

How To Display A BMP or GIF-File?

This is the source code for a BMP loader by Aaron Scott Zabudsky.

This is the source code for a GIF loader by a Rich Geldreich..


This is done using the ON KEY x GOSUB statement, like this:
KEY 15, CHR$(&H04) + CHR$(70) 'CTRL-BREAK
KEY 16, CHR$(&H04) + CHR$(&H08) + CHR$(83) 'CTRL-ALT-DEL
ON KEY (15) GOSUB 100
ON KEY (16) GOSUB 200


100 PRINT "CTRL-BREAK pressed."

200 PRINT "CTRL-ALT-DEL pressed."
This, however, may not work on all systems.
This tip was contributed by
Jim Oliver.

Another way of disabling CTRL-BREAK is as follows:

' DISABLE CTRL-BREAK:                                              
dim brk$(3)
' First save the current vectors:                                  
def seg=0: for i=108 to 111: brk$(i-108)=str$(peek(i)): next       
' Then poke new interrupt vectors:                                 
poke 108,83: poke 109,255: poke 110,0: poke 111,240: def seg       

' RESTORE CTRL-BREAK:                                              
def seg=0: for i=108 to 111: poke i,val(brk$(i-108)): next: def seg
Do make sure you reenable CTRL-BREAK before exiting your program, or it will stay disabled.
This tip came from Foon.

How To Return An Errorlevel From Your Program?

You must DECLARE an undocumented routine in the default LIB/QLB like so
and use CALL Name in place of END or SYSTEM. Name can be whatever you choose to name it except a QB reserved word, I used 'Bye'. The value passed must be between 0 and 255, including 0 and 255.

N may also be replaced by what ever you see fit to name the variable.

This tip was contributed by Dan Hudson.

How Use Your SoundBlaster?

here to go to a document describing various SoundBlaster techniques.

How To Read A .DBF-File?

here to see how to print listings of dBase III+ or IV .DBF-files. The code came from Jos Szabo.

How To Control COM3?

here to see an example of how to swap COM ports 2 and 3, so you can use COM3.
It came from Maria Mukurasi.

How To Convert A Number To Binary And Extract A Bit From It?

here to see a piece of code that illustrates how to do that, contributed by Douggie Green.

How To Do Accurate Timing In BASIC?

here to see how to achieve very accurate [far better than with the TIMER system variable] timing in BASIC. This piece of code was written by Zabudsky Aaron Scott.

How To Do CRC-Checking?

here to see an example of both CRC-16 and CRC-32 checking, by Coridon Henshaw.

How To Reboot The Computer From Within A BASIC Program?

This is done by means of this instruction:
OUT &h64, &hfe
This tip came from
Karl D. Peralta.

How To Print Graphics Using BASIC?

Extensive information about printing graphics is available from the
Printing Grahics pages by Marnix Bindels.

How To Do Controlled Text Input in BASIC?

In many situations, the standard input statements INPUT$ or LINE INPUT$ are not adequate. The length of the text cannot be limited, so your screen layout may become cluttered. Also, the program only continues when the Enter-key is pressed, and in many situations, it can be useful to be able to react to other keypresses as well.

The Edit-function enables you to control the length of the input field, provide a default text and react to arrow keys, PgUp, PgDn, function keys, Esc and Enter. For the user, it gives full text editing possibilities, including Insert/Typeover switching with Insert and character erasing with Backspace and Delete.

The Edit-function is included in a demonstration program, SHOPLIST.BAS, which clearly illustrates the use of the function. The arguments of the function are three integers: the screen row and column of the first character of the input field, and the length of the input field. The fourth argument should be a string variable of sufficient length to hold the text. Note that the function changes the contents of this variable to the text put in. The return value is the ASCII-value or the scan code of the key that was used to end the input. Use the constants that are defined at the start of the program to compare the return value with, as shown in SHOPLIST.BAS. FgCol and BgCol are constants defining the foreground and background colours.

How To Read From And Write To The Text Screen Directly?

Characters are stored in het video memory using two bytes per character. The first is the ASCII code of the character and the second the colour, using the formula value = foreground + 16 x background + 128 x blinking, where foreground is the foreground colour ranging 0-15, background is the background colour ranging 0-7 and blinking is either 0 or 1. To read or write characters directly from the screen, you can use PEEK and POKE like this:
DEF SEG = &HB800
POKE 0,65 'Put an A in the top left corner
POKE 1,1 'Colour it blue
X = PEEK(157) 'Get ASCII value for character in top right corner
Thanks to
Egbert Zijlema.

How To Convert an Interpreted BASIC File to an ASCII Format File?

GW-BASIC saves basic files in a compressed format, unless you specify the ,A after the file name. If you don't have GW-BASIC, you can use
RB version 1.58 to convert the files to ASCII
Thanks to Geoffrey Coram.
Please send any contributions to

Go back to the BASIC homepage.