Extract from Ethan Winer's "PC Magazine's BASIC Techniques and Utilities"
as uploaded to CompuServe by him. Because Ziff Davis found it unprofitable
to sell this book any longer, they gave all rights back to Ethan Winer.
This is an excellent book for any QB/PDS/VBDOS programmers to read.
BASIC has always been the most popular language for personal computers.
It is easy to learn and use, extremely powerful, and some form of BASIC is
included for free with nearly every PC. Although BASIC is often associated
with beginners and students, it is in fact ideally suited for a wide range
of programming projects. Because it offers the best features of a high-
level language coupled with direct access to DOS and BIOS system services,
BASIC is fast becoming the language of choice for beginners and
professional developers alike.
A BRIEF HISTORY OF MICROSOFT COMPILED BASIC
In March of 1982, IBM released the first BASIC compiler for the IBM PC.
This compiler, BASCOM 1.0, was written by Microsoft for IBM using code and
methods developed by Bill Gates, Greg Whitten, and others. Although
Microsoft had already written BASIC compilers for the Apple II and CP/M
computers, BASCOM 1.0 was the most powerful they had produced so far.
Compared to the Microsoft BASIC interpreters available at that time,
BASCOM 1.0 offered many additional capabilities, and also an enormous
increase in program execution speed. Line numbers were no longer
mandatory, program statements could exceed 255 characters, and a single
string could be as long as 32,767 characters. Further, assembly language
subroutines could be linked directly to a compiled BASIC application.
Over the next few years, Microsoft continued to enhance the compiler,
and in 1985 it was released by IBM as BASCOM 2.0. This version offered
many improvements over the older BASCOM 1.0. Among the most important were
multi-line DEF FN functions, dynamic arrays, descriptive line labels (as
opposed to numbers), network record locking, and an ISAM file handler.
With named subroutines programmers were finally able to exceed the 64K code
size limitation, by writing separate modules that could then be linked
together. The inclusion of subroutine parameters--long overdue for BASIC-
-was an equally important step toward fostering structured programming
techniques in the language.
At the same time that IBM released BASCOM 2.0, Microsoft offered
essentially the same product as QuickBASIC 1.0, but without the ISAM file
handler. However, there was one other big difference between these
compilers: QuickBASIC 1.0 carried a list price of only $99. This low price
was perhaps the most important feature of all, because high-performance
BASIC was finally available to everyone, and not just professional
Encouraged by the tremendous acceptance of QuickBASIC 1.0, Microsoft
quickly followed that with QuickBASIC version 2.0 in early 1986. This
important new release added an integrated editing environment, as well as
EGA graphics capabilities. The editor was especially welcome, because it
allowed programs to be developed and tested very rapidly. The environment
was further enhanced with the advent of Quick Libraries, which allowed
assembly language subroutines to be easily added to a BASIC program. Quick
Libraries also helped launch the start of a new class of BASIC product:
third-party add-on libraries.
In early 1987 Microsoft released the next major enhancement to
QuickBASIC, version 3.0. QuickBASIC 3.0 included a limited form of step
and trace debugging, as well as the ability to monitor a variable's value
continuously during program execution. Also added was support for the
EGA's 43-line text mode, and several new language features. Perhaps most
impressive of the new features was the control flow statements DO and LOOP,
and SELECT CASE. Beyond merely providing a useful alternative to the IF
statement, these constructs also let the compiler generate more efficient
Also added with version 3.0 was optional support for an 8087 numeric
coprocessor. In order to support a coprocessor, however, Microsoft had to
abandon their own proprietary numeric format.
Both the Microsoft and IEEE methods for storing single- and double
precision numbers use four bytes and eight bytes respectively, but the bits
are organized differently. Although the IEEE format which the 8087
requires is substantially slower than Microsoft's own, it is the current
standard. Therefore, a second version of the compiler was included solely
to support IEEE math.
By the time QuickBASIC 4.0 was announced in late 1987, hundreds of
thousands of copies of QuickBASIC were already in use world-wide. With
QuickBASIC 4.0, Microsoft had created the most sophisticated programming
environment ever seen in a main-stream language: the threaded p-code
interpreter. This remarkable technology allowed programmers to enjoy the
best features of an interpreted language, but with the execution speed of
In addition to an Immediate mode whereby program statements could be
executed one by one, QuickBASIC 4.0 also supported program break-points,
monitoring the value of multiple variables and expressions, and even
stepping *backwards* through a program. This greatly enhanced the
debugging capabilities of the language, and increased programmer
Also new in QuickBASIC 4.0 was support for inter-language calling.
Although this meant that a program written in Microsoft BASIC could now
call subroutines written in any of the other Microsoft languages, it also
meant that IEEE math was no longer an option--it became mandatory. When
a QuickBASIC 4.0 program was run on a PC equipped with a coprocessor,
floating point math was performed very quickly indeed. However, it was
very much slower on every other computer! This remained a sore point for
many BASIC programmers, until Microsoft introduced BASIC 6.0 later that
year. That version included an alternate math library that was similar to
their original proprietary format.
Also added in QuickBASIC 4.0 were huge arrays, long (4-byte) integer
variables, user-defined TYPE variables, fixed-length strings, true
functions, and support for CodeView debugging. With the introduction of
huge arrays, BASIC programmers could create arrays that exceeded 64K in
size, with only a few restrictions. TYPE variables let the programmer
define a composite data type comprised of any mix of BASIC's intrinsic
data forms, thus adding structure to a program's data as well as to its
code. The newly added FUNCTION procedures greatly improved on BASIC's
earlier DEF FN-style functions by allowing recursion, the passing of TYPE
variables and entire arrays as arguments, and the ability to modify an
Although BASIC 6.0 provided essentially the same environment and
compiler as QuickBASIC 4.0, it also included the ability to create programs
that could be run under OS/2. Other features of this release were a
utility program to create custom run-time libraries, and a copy of the
Microsoft Programmer's Editor. The custom run-time utility was
particularly valuable, since it allowed programmers to combine frequently-
used subroutines with the BRUN.EXE language library, and then share those
routines among any number of chained modules.
QuickBASIC 4.5 was introduced in 1988, although the only major
enhancement over the earlier 4.0 version was a new help system and slightly
improved pull-down menus. Unfortunately, the new menus required much more
memory than QuickBASIC 4.0, and the "improved" environment reduced the
memory available for programs and data by approximately 40K. To this day,
many programmers continue to use QuickBASIC 4.0 precisely because of its
increased program capacity.
In answer to programmer's demands for more string memory and smaller,
more efficient programs, Microsoft released the BASIC Professional
Development System version 7.0 in late 1989. This was an enormous project
even for a company the size of Microsoft, and at one point more than fifty
programmers were working on the new compiler and QBX environment. PDS
version 7.0 finally let BASIC programmers exceed the usual 64K string
memory limit, albeit with some limitations.
Other features introduced with that version were an ISAM file handler,
improved library granularity, example tool box packages for creating simple
graphics and pull-down menus, local error handling, arrays within TYPE
variables, and greatly improved documentation. Because the QBX editor uses
expanded memory to store subprograms and functions, much larger programs
could be developed without resorting to editing and compiling outside of
Sixth months later PDS version 7.1 was released, with the long-overdue
ability to redimension an array but without destroying its contents. Also
added in that version were support for passing fixed-length string arrays
to subprograms and functions, and an option to pass parameters by value to
BASIC procedures. Although the BYVAL option had been available since
QuickBASIC 4.0, it was useable only with subroutines written in non-BASIC
languages. With this mechanism, BASIC can now create more efficient object
code than ever before.
[Just as this book was being completed, Microsoft released Visual Basic
for DOS. Although this book does not address VB/DOS specifically, most of
the information about BASIC PDS applies to VB/DOS. One notable exception
is that VB/DOS supports far strings only, where BASIC PDS lets you specify
either near strings or far. Because far strings are stored in a separate
"far" area of DOS memory, it takes slightly longer to access those strings.
Therefore, a VB/DOS program that is string-intensive will not be as fast
as an equivalent compiled with QuickBASIC or with PDS near strings. This
book also does not cover the pseudo event-driven forms used by VB/DOS.]
ABOUT THE AUTHOR
Ethan Winer is the founder of Crescent Software, Inc. located Ridgefield
Connecticut. He has programmed in BASIC and assembly language since 1980,
and is the author of Crescent's QuickPak Professional and P.D.Q. products.
Ethan has also served as a contributing editor for both PC Magazine and
BASICPro (now Visual Basic Programmer's Journal), and has written numerous
feature articles for other popular computer publications. In 1992 Ethan
retired from writing software professionally, and now spends his free time
writing and performing music.