QuickBasic

Jason Mallory

CSC 415: Programming Languages

Dr. Lyle

November 16, 2011

Development

QuickBasic was the precursor to Visual Basic and its development was based on GW-Basic ("QuickBasic." ). First released in 1985, it was sold only on 5.25” floppy disk, despite 3.5” drives replacing the older hardware. Version 2, released in ’86, introduced the IDE that would persist until the final release, QuickBasic 4.5, that hit the market in 1988 (Perry, Z).

QBasic, a subset of QuickBasic, was distributed with versions of DOS 5.0 and later, which replaced GW-Basic that had been shipped previously.QuickBasic expanded upon GW-Basic by adding newer features like user defined data types, control structures, better graphics support and an integrated compiler.("QuickBasic.")

QuickBasic, despite being nearly 3 decades old and that it has not been supported for almost as long, still sees use today. Within the hobbyist programming communities, it is still being used to create simple games, software for small personal businesses and as of late, it has been used to allow machines as old as the 8088 to be networked("QuickBasic.").

Data Types

QuickBasic data types included strings, integers, long integers, single precision, double precision, and user defined data types. Variables could be declared in one of two ways. You could use either DIMname AStype or you could append the variable name with a symbol to declare its type when it was initialized. The symbols used were $ for strings, % for integers, for long integers, !forsingle precision, and # fordoubleprecision. Given that QuickBasic did not have a character data type, strings were a data type of its own rather than being an array of characters like many other languages. Arrays have to be declared using the dim method and appending the variable name with the dimensions of the array like DIM name(x,y,z,etc.) AS type.

From what can be inferred from the application help file, it would appear that numeric variables were always signed 32 bit values. Reserved words could not be used for variable names and QuickBasic was not case sensitive.

Variables in QuickBasic were locally scoped whereas some other BASIC languages used only global scoping. One bonus to the methods used to declare variables was when it came to procedures. While the appended symbol method was convenient for easily seeing the variables type, the DIMname AS type method allowed you to change the type by simply changing the type keyword. Through the SHARED keyword, variables could be used out of scope, increasing the ease of code reusability (Noggle, 80).

Arithmetic, Relational, and Logical Operators

QuickBasic possessed the standard stable of arithmetic operators such as exponentiation (^), negation (-), multiplication and division (*, /), integer division (\), modulo arithmetic (MOD), and addition and subtraction (+, -), with an operator precedence of the order given.

Relation operators included equal to (=), greater then (>), less than (<), not equal to (>), less than or equal to (<=), and greater than or equal to (>=).

In regards to logical operators, QuickBasic supported operators for not (NOT), and (AND), or (OR), exclusive or (XOR), equivalent or if and only if
(EQV), material implication or X implies Y (IMP).

Program Structure

Microsoftmade the move to a more structured format from the start with QuickBasic and with newer versions, continued to improve upon this. QuickBasic still supported line numbers and program jumps, although these led to spaghetti code that was difficult to follow and maintain. (QuickBasic) Control structures like IF…THEN…ELSE, SELECT CASE…CASE1…CASE2…CASE ELSE…END SELECT, DO WHILE…LOOP, DO UNTIL…LOOP, and for loops in the form of FOR…NEXT were supported in QuickBasic.These included both block and single line verses. The inclusion of these,as well as functions and procedures, allowed for the creation of more professional code.

Subprograms

QuickBasic supported procedures, but they were stored and written separately from the main program file. Through the use of the SUB keyword, the editor would take you to a new window as soon as the procedure was declared ("QBASIC Programming for Kids."). The syntax for declaring a procedure was as follows:

SUB name[parameterList]

[statements]

[EXIT SUB]

[statements]

EXIT SUB

Through the use of subprograms and user defined data types, something that resembled object oriented programming could be accomplished.

Exception/Error Handling

QuickBasic supported error handling through the ON ERROR GOTOlabelstatement. This statement tells the program what label to go to in the event of an error. ERR, a variable that holds a code related to the error, is then used in a SELECT CASE statement to designate how each error is handled.RESUME NEXT is used after the select case to allow the program to continue.

Readability, Writability, and Reliability

QuickBasic, being part of the BASIC family, was meant to be a user friendly language. It was marketed by Microsoft as “the introductory level for their BASIC Professional Development System.” ("QuickBasic.") QuickBasic code is fairly easy to follow and readwhen compared to other languages. Other languages use many abbreviations, but QuickBasic’s code looked almost like a set of instructions given in English. For an example of a complete QuickBasic program, see the appendix:A QuickBasic Example Program.

The English like syntax, while making it more readable, has an impact on its writability via the sheer number of keystrokes needed to complete a task. This is balanced by the fact that writing QuickBasic code feels like naturally explaining a task.

Regarding reliability, QuickBasic had some differences between the interpreter and the compiler. This meant that code that execute is the interpreter may not compile. ("QuickBASIC." ) Newer versions of QuickBasic were backwards compatible with previous versions.

Overview

Overall QuickBasic was a language that performed it task. It was a language that was easy to learn. It provided the means to create professional code. During it’s lifetime it was a language that supported the features of it’s day. QuickBasic was a solid language that is used to solve problem, even to this day.

Appendix: A QuickBasic Example Program.

The following is an example program from the 99 Bottles of Beer website. This site is a collection of source code in many different languages that will generate the lyrics to the song “99 Bottles of Beer.” This specific version can be found at:

Language QuickBASIC

(boolean algebra, "four phrase" logic)

Date: / 01/19/08
Author: / Al Boulley
URL: / n/a
Comments: / 1
Info: / n/a
Score: / (3.12 in 24 votes)

'set fridge capacity, beverage type, and container type

X = 99

B$ = "beer"

C$ = "bottle"

'build number strings so "0" can be sung correctly in second to last verse

DIM N$(X)

FOR L = 1 TO X

N$(L) = LTRIM$(STR$(L))

NEXT

N$(0) = "no more"

'fully stock the fridge, and then start singing!

F = X

DO

'each verse has four "phrases"

FOR P = 1 TO 4

SELECT CASE P:

'three phrases are very similar - first, second, and fourth

CASE 1, 2, 4:

'use some boolean algebra to handle the "what-ifs":

PRINT N$(F); " "; C$; LEFT$("s", -(F > 1)); " of "; B$;

'-(F=1) evaluates to 1 when F=1.... [-(-1)]

' 0 when F>1... [-(0) ]

'(don't want to pluralize a lone container)

PRINT LEFT$(" on the wall", -12 * (P > 2));

'-12*(P>2) evaluates to 0 when P=2.... [-12*(0) ]

' 12 when P>2... [-12*(-1)]

'(don't want to sing those words in the second phrase)

PRINT MID$(", ." + CHR$(13), 3 + 2 * (P = 1), 2);

'3+2*(P=1) evaluates to 1 when P=1.... [3+2*(-1)]

' 3 when P>1... [3+2*(0) ]

'(brief pause after first phrase, long pause after other two)

'[using length of zero with Left$ results in empty string]

'third phrase of the song never changes

CASE 3:

PRINT "Take one down and pass it around, ";

F = F - 1

END SELECT

NEXT

'take an extra breath between verses

PRINT

'F evaluates to FALSE when F=0 [exactly zero is always FALSE]

' TRUE when F>0 [every nonzero is always TRUE]

'(continue singing verses until fridge is empty)

LOOP WHILE F

'sing final verse the easy way

PRINT "No more "; C$; "s of "; B$; " on the wall, no more "; C$; " of "; B$; "."

PRINT "Go to the store and buy some more, "; N$(X); " "; C$; "s of "; B$; " on the wall."

'boolean algebra is your friend :)

Bibliography

Joseph, Noggle H. QuickBasic Programming for Scientists and Engineers. CRC, 1992.Web.

Perry, Z. "Programming: QBASIC History Timeline." Associated Content from Yahoo! - Associatedcontent.com. Web. 22 Nov. 2011. <

"QBASIC Programming for Kids." Ted Felix's Home Page. Web. 22 Nov. 2011. <

"QuickBASIC." Wikipedia, the Free Encyclopedia. Web. 22 Nov. 2011. <