Quickbasic (Version 4.5): a User- Friendly Computer Programming Tool
Total Page:16
File Type:pdf, Size:1020Kb
QuickBASIC (version 4.5): a user- friendly computer programming tool J. CASE Among those with pretensions to computer literacy, as supplied with IBM and IBM-compatible computers, the BASIC progtamming language is commonly spoken are interpreters of the BASIC language. They are easy of with contempt. However appropriate that may seem to learn and use but will inevitably lead the amateur to someone with the intelligence and perseverance to programmer into bad habits that may prove difficult become proficient in Pascal, it overlooks the purpose to break. Early compilers did not always improve the for which BASIC was written in the first place. The situation. They merely converted programs that had acronym stands for Beginners’ All-purpose Symbolic been written and tested using the interpreter. Modern Instruction Code. For beginners, its easy-to-learn syntax BASIC compilers, however, offer a complete program- makes BASIC an ideal choice for those wanting to jump ming environment, making the interpreted form of the right in and write functional software with little or no language virtually redundant. Among those currently prior preparation. It’s a pity that the same simplicity available, Microsoft’s QuickBASIC Version 4.5 may be of use leads to the creation of inelegant code and so considered one of the worlds best bargains in computer readily engenders bad programming habits. software. At any rate, it has qualities that justly entitle With languages like C and Pascal, all variables have BASIC to the same respect that is so commonly paid to he declared before being applied. A considerable to the more posh computer languages. It is easy to learn, amount of preparatorytime must be spent in designing yet has capabilities hitherto found only in Pascal and the program before it can be written and tested. BASIC, the like. It allows for structured programming and is on the other hand, has an almost limitless capacity to no more complicated to work with than some of the tolerate last-minute changes. Fresh lines of code can simplest of word processors. be created as necessity dictates, and, by being numbered appropriately, can be executed in almost any order The Compiler versus Interpreter flow of the program can be directed to the new code Before going on to consider the many virtues of at will with a simple GOTO statement-or, perhaps a QuickBASIC, it may be helpful to review briefly the little more forgivably, by using GOSUB and RETURN. essential differences between an interpreted and a com- The same simplicity of use is one of the main disad- piled version of a computer program. vantages of BASIC. Unplanned changes lead to the An interpreter translates each statement of code into generation of “spaghetti code,” winding its way intri- machine language as it goes along. Providing the syntax cately from one part of the program to another and and grammar are correct, the statement is then executed coiling back on itself in infinite complexity. Therein by the computer and the interpreter proceeds to the lies the fundamental distinction between structured and next one. If an error is encountered, the program stops unstructured progamming. Therein, too, is the difference and an error message is displayed. When a statement between code that is interpretable when the need arises occurs more than once in a program, the interpreter to change it and code that defies unraveling, even by approaches it afresh each time, laboriously translating the misguided soul responsible for its creation. it again. Consequently, the execution of a home-made All the bad things people say about BASIC are largely BASIC program can seem painfully slow by comparison true enough as they apply to the interpreted form of with professionally written software, whether of com- the language that is usually supplied with a computer’s mercial origin or otherwise. Naturally, the program is operating system. To be fair, all the good things they incapable of running on its own. The BASIC interpreter say are true, too, for that matter. BASICA and GWBASIC, must be loaded first, since it has to be present to con- VOLUME 5, NUMBER 1, 1989 15 J. CASE vert the code into instructions the computer can Subsequent Developments understand. The introduction of Version 2 of QuickSASIC in 1986 A compiler, by contrast, translates all statements of brought several significant practical improvements. The code into the necessary machine language in advance, provision of a full-screen editor enabled a QuickBASIC converting them into a stand-alone program that can program to be wholly written within the environment he executed directly from the DOS command line. The of the compiler. Moreover, the ability to dispense with gain in convenience and speed is impressive. It is not line numbers brought true structured programming in unusual for a compiled BASIC program to run 30 or BASIC within easy reach. At the same time, this was 40 times faster than did the original code under the not imposed as an inescapable condition, as it is in interpreter. Pascal. There were other significant improvements, as The first BASIC compiler for the IBM PC retailed at there were, again, with Version 3 and, more recently, a price around $600. That was too high a figure to with Versions 4.0 and 4.5. No doubt the future will deserve serious consideration by an amateur pro- see further improvements that would be hard to imagine grammer From that viewpoint, Version 1 of QuickBASIC at this point. In the meantime, QuickBASIC 4.5 is just came as a Godsend when it was introduced at a list about everything the amateur programmer could wish price under $100 in 1985. At that point, however, it for. did little to improve the structure of a BASIC program. It was still necessary to use the interpreter to write and Using QuickBASIC, Version 4.5 test the code for errors before going on to compile it. All that is needed to create a new program is to load The procedure was cumbersome and inconvenient. For the compiler by typing “QB” at the DOS prompt, then one thing, the BASIC interpreter saves its files to disk select the “New program” option from the “File” menu, in a “tokenized” form that the compiler is incapable and start typing. Naturally, it is assumed that the user of reading. It was necessary to remember to use the is familiar with interpretative BASIC and thus already switch that causes the file to be written in ASCII format. knows the syntax and functions of the language. If not, After that, it was necessary to exit the interpreter, then however, Version 4.5 possesses a useful feature not invoke the compiler to convert the BASIC source code present in Version 4.0. This is the ability to bring up into an OBJect file. Finally, the OBJect file had to be context-sensitive help on the screen. Pressing Function LlNKed with another utility to create the stand-alone Key 1 while the cursor is on a BASIC statement brings EXEcutable program that was the original objective. up a display that explains the use of that statement in All this could be extremely tedious, to say the least, complete and helpful detail. This remarkable enhance- especially as the compiler commonly reported errors ment makes the manual redundant (although one can not previously suspected. A few programming practices still be purchased at extra cost). tolerated by the interpreterwere disallowed by the com- In writing a program, errors of syntax are recognized piler; hence, it was frequently necessary to reload the as they are entered, thanks to the ‘Smart editor” feature interpreter to amend and retest the source code In saving of the compiler. This can be very useful as an aid in the corrected program each time, it was again essential writing error-free code, but it is also irritating at times. to remember the compiler’s aversion to the tokenized Mercifully, it can be turned off, if desired. Several format used as the default by the interpreter. And, after significantly enhanced functions have been incorporated. each revision, it a necessary to return from the inter- For one thing, IF. .THEN. .ELSE constructions are preter to the DOS command line, then load the compiler easier to use, as they are no longer confined to one line, again for further action. and a DO. ..UNTIL loop has also been made available More recent updates of the compiler embodied signifi- to supplement the more limited capabilities of FOR. cant improvements. Version 4.5, still at a list price of TO and WHILE. .WEND. The lack of line numbers under $100 (and available for as little as $65 from a does not preclude the use of GOTO or GOSUB and wide selection of discount software retailers), is as dif- RETURN, either. They are to be avoided ifpossible, but ferent from Version 1 as chalk is from cheese. It is also it is sometimes useful to be able to divert the flow of as little deserving of the criticism heaped on BASIC by the program at will. If necessary, an alphabetic or the programming snobs as even the most respectable alphanumeric label can be assigned to facilitate reaching of computer languages, whatever that is considered to be. the appropriate line(s) of code. This can be made descrip- 16 IMMUNOHEMATOLOGY QuickBASIC program (version 4.5) tive of the purpose served by those lines of code. For saved. If an additional existing module is to be included instance, a subroutine to read a diskfile can be labeled in a program alreadyloaded, the “Merge” option from ReadFile: and invoked by placing the command GOSUB the “Edit” menu enables it to be incorporated.