After a disappointing first version of Basic for the Mac, Microsoft bounces back with an excellent version 2.0. A Basic improvement, says Bryan Skinner.
Better Basic
After a disappointing first version of Basic for the Mac, Microsoft bounces back with an excellent version 2.0. A Basic improvement, says Bryan Skinner
Microsoft and Basic - the two words are inextricably linked in the minds of micro users. Microsoft has licensed its product to so many OEMs that a version of MBasic is the first programming language for thousands of hackers. Yet Basic is often criticised for its slowness and lack of structure.
When the Macintosh appeared it looked the perfect machine for a highly developed Basic, but Microsoft's Basic Version 1.0 was a disappointment. Sure, you could make calls to the Mac's ROM routines for drawing circules, arcs, rectangles, and it was fast - which you'd expect from any application running on a 68000 - but otherwise it was pretty ordinary.
Features
Now version 2.0 is available, and what an eye-opener: it's easily the best Basic I've ever used. What makes it so different? For a start, line numbers are optional and you can GOTO a label. Version 2.0 supports event interruption, there's ON TIMER, which can be passed intervals between 1 and 86400 seconds (24 hrs); ON MOUSE for mouse button presses and ON MENU for user-menu selections. Also included are ON DIALOG and MENU definitions - yes, you can program all that window stuff with the greatest of ease. Similarly, there are fistfuls of button, mouse, window and other "WIMPish" instructions.
You can write professional-looking programs without resorting to lengthy and complex code. For example, I wanted to write a program to send an ASCII text file from disk to one of the serial ports, for downloading to a lap portable. With most Basics you'd have to get the user to enter the file name, and include error traps for "File not found" problems.
With Basic 2.0 you simply use "afile$=FILES$(1)". When the program hits this, a window appears containing all the files on disk (in alphabetical order, what's more). There's a scroll bar so you can easily get the file you want in the window. If the file you want isn't on the current disk there's an EJECT button to be clicked. When your file appears, just move the cursor anywhere over its name, click the mouse button, then the OPEN box, and control passes back to the program with the name of the selected file in the variable "afile$". It's that easy - just one assignment statement does what would otherwise require detailed system knowledge and a long piece of code.
Procedures are also catered for, defined by SUB and END SUB. Parameter passing allows variables to be static or shared, i.e. local and global. Version 2.0 retains all the fancy text/graphics stuff, such as altering text fonts and sizes, drawing circles, ovals and rectangles, and framing and filling shapes. You can store all graphics commands issued, so they can be saved in a single string - PICTURE$ - and there's even a SCROLL command for pixel scrolling of rectangles in the four basic compass headings.
With SOUND you can specify frequency, duration and volume for tones using the Mac's four voices, while WAVE lets you define tone waveforms. Would you believe the latter needs an integer array of no fewer than 256 elements? You can queue sounds and specify the phase of the waveform by stating the array element at which the definition is to begin.
of Basic 2.0. They're both about 80K, the different being internal numeric representation. One offers BCD maths (Binary Coded Decimal - the same as Basic 1.0), the other IEEE (binary). The latter is better for engineering oriented applications and gives faster run-time code, particularly for trigonometric functions.
In Use
Basic 2.0 isn't just one of the most powerful languages around, it's also a doddle to use. You can open two LIST windows, allowing you to operate on different sections of code at once. Unlike version 1.0, editing is within these windows, and with the mouse, cut, copy and paste facilities, makes full-screen editors look a bit Mickey Mouse. Produce an error and a LIST window appears with the offending statement framed and of course there's a full set of error messages.
Naturally, the language and its programming environment aren't flawless. There's still the tortuous LSET, RSET, MKS$, MKI$ and what have you for random access files. It's hard to see how this could be improved, and with practice they become second nature.
Basic 2.0 is fussy about spaces. I've got used to leaving them out to save RAM on the portable, and when I uploaded a program I spent ages inserting spaces between reserved words and variables. It's the price for being allowed to embed reserved words in variable names. However, since the editor puts reserved words in bold type, spotting problems is easy.
One major oversight is that when you OPEN COM1: or LPT: for interfacing you can't specify X-ON/X-OFF or SHIFT IN/SHIFT OUT, which means you'd have to handle these protocols as part of your own I/O routines, or work at the rather slow rate of 300 baud. On the plus side, you can open the clipboard for I/O, which allows you to transport data between Basic and other applications such as Multiplan.
Documentation
The documentation is typical Microsoft, well-written, but rather short on worked examples. What samples of code there are tend to be duplicated, so you have the same fragments to explain two or three reserved words.
This is off-set by several sample files, ranging from a simple ellipse drawing program to a handy serial port setter to an extremely useful cross-referencer. The latter checks a program for such errors as duplicate labels - very nice. But searching for text in a large file can be slow when the system has to perform a lot of disk accessing.
Verdict
All in all Basic 2.0 for the Macintosh is as near perfect as you could wish. It's got every facility I've seen in any version, plus a whole lot more. To top that, it provides a sophisticated programming environment.
The package points the way to future Basics and I bet the Commodore, Atari and other 'super' micros won't offer anything near it.
Mac owners should seriously consider buying Basic 2.0, if only to see what the best version of the language looks like. Whether you're familiar with Basic, or a novice to programming, you'll be staggered by its power and ease of use.
Report Card
Features 5/5 Documentation 5/5 Performance 4/5 Overall value 5/5