PowerBASIC 3.0. (Spectra Publishing) (Software Review) (Evaluation)
by Tom Campbell
There's a sparkling "new" BASIC on the scene, one that might be familiar to old hands. PowerBASIC 3.0 from Spectra Publishing (1030-D East Duane Avenue, Sunnyvale, California 94086, 408-730-9616) has just been released, and it's very hot. If the name doesn't ring a bell, it used to be Borland's Turbo Basic two versions ago. PowerBASIC 2.0 was the first release from Spectra, and I loved it.
Uppermost in many people's minds is: How compatible is PowerBASIC with Microsoft's QuickBASIC? The answer is that they're fairly close. But any large program will probably require major rewriting.
PowerBASIC is a lightning-fast native code compiler, just like QuickBASIC's Make EXE file option. But this one always compiles, and it compiles insanely fast. For large projects, you can break programs up into precompiled versions called units, just like Turbo Pascal's. You can also use OBJ files, but they aren't as good as units.
PowerBASIC has a ton of new features. My favorite by a landslide is its ability to create any kind of TSR imaginable. TSRs can be triggered by hot keys, by interrupts, by timer ticks, and by a few less obvious methods. You can swap them out to EMS memory or a disk file, so that the executable can be 200K yet still consume only 4.5K of conventional memory. The TSRs are quite stable, working well under my rather strenuous test conditions. In all, this feature alone is worth buying the product if you need to develop TSRs. It's cheaper than many C libraries that offer the same feature, yet it offers the convenience of BASIC. Related to that is the new ASM statement (with the alias !for brevity), which allows you to embed assembly language statements right into the BASIC code.
A less sexy feature (but perhaps a more important one) is the ability to create huge arrays, which may contain more than 64K of data. Unlike "the other BASIC," PowerBASIC lets you create these huge arrays in any size, not just a space-wasting power-of-two dimension. Hand in hand with huge arrays is the ability to create compound data types--not only the TYPE variety, but the UNION variety as well, which lets you overlap similar data structures, like the variant records of Pascal or the union of C. And anyone who writes directly to the screen or reads from the BIOS frequently will appreciate the ability to declare arrays at an absolute memory location. Ever since Turbo Pascal added this one, I've been champing at the bit for a better DEF SEG.
Last on the list of my favorite new features is the addition of a deceptively simple option that requires you to declare variables before using them. Although this seems like a cruel trick on BASIC programmers, I have found it absolutely essential on large projects. Until now I haven't been able to use BASIC for programs over a thousand lines or so because BASIC will simply initialize to zero any new variable it finds. Too many times, my development has ground to a halt at 2:00 in the morning while I read and reread my code, missing every time that an array called SymTable has quietly transmogrified into SymbolTable. That C and Pascal require variable declarations went from an onerous burden to a basic requirement. Now I can look forward to using PowerBASIC even in serious development.
Besides these major new additions that hit home with me, there are scores of other features you'll find it hard to resist, such as byte, word, and double-word types (all unsigned, at last!); ON ERROR LOCAL for intraroutine error trapping; an editor that can handle huge files and, finally, mice; reasonably good hypertext help; and a stand-alone debugger. But call for a brochure--there are even more.
This month's program is written in PowerBASIC and is available on CompuServe in the IBMPRO forum under the file-name DBFDIR.BAS. If you have any trouble finding it, you can send me E-mail at 75530,3607. It both highlights and improves one of PowerBASIC's most useful features, the DIR$ function. DIR$ is meant to be called once with a file specification, such as "C:/DBF/*.DBF", and after that in a loop without the file specification. The first time it's called, it returns the first file matching the specification; the second time, and on subsequent invocations without a parameter, it returns the remaining matches. The problem is that it only returns a filename and extension, not the drive and path. So, in the example of "C:/DBF/*.DBF", it might return "TODO.DBF", "ACCTS.DBF", and so on, but not "C:/DBF/TODO.DBF", and so forth. DBFDIR.BAS, the PowerBASIC program I wrote, acts like dBASE's Dir command and lists database characteristics (last update and record size) of all the dBASE data files in the specified directory. I ported SplitFilename$ from an earlier column with no effort at all; it's used to reconstruct the matching filenames so they can be opened and the DBF header data read in. As usual, this is modular code, so you can easily hollow out the dBASE-specific portion and just use the framework for your own files.