CBasic and the GSX Module. (IBM Images) Susan Glinert-Cole.
Digital Research threw in the towel with regard to the place of CP/M in the 16-bit world and now offers their very popular compilers under PC-DOS. I have had the opportunity to look at two of them briefly: Pascal MT+ and CBasic with the graphics extension (GSX-86). Both languages have features unavailable in the comparable Microsoft version. MT+ for example, supports overlays, allows in-line assembly code, and lets you painlessly perform DOS function calls from within a program.
The CBasic compiler has some handy bells and whistles like COMMAND$, which returs a command string used when the program weas invoked. MATCH returns the position of the first occurence of a particular character pattern in a string. SADD returns the address of a specified string. UCASE$ will convert lowercase characters to uppercase.
There are also several statements and functions in CBasic designed for use in multi-user/tasking environments. For example, ATTACH returns a Boolean value indicating whether or not a specified printer is available for program use. If the printer is available, ATTACH attaches it to the program, thus allowing it to be accessed. DETACH does the opposite, making the printer unavailable to the applications program. The functions LOCK and its opposite number, UNLOCK, are used for coordinating record access in a multi-user situation. LOCK prevents a program from modifying a record; UNLOCK releases the record for write access.
CBasic does not support any music functions in the present version (2.1), nor is there the elaborate range of "ON (device) GOSUB" available in MS-Basic.
The documentation is uneven; in some places it is lucid, while in others it tends to wander and confuse by omission. There are several reserved words for which no explanation is given. Both the MT+ and the CBasic compilers hava a very difficult time with the end of a source code file. MT+ absolutely requires a carriage return after the final END statement. If this is omitted, the compiler freezes the systems, requiring a hard reset. The CB compiler was very unhappy about the way my text editor ends a file (it does not insert any control characters). The compiler found 47 errors of the "invalid character in source file" when it failed to locate a Ctrl-Z after the final END statement. It was, however, indifferent to the presence or absence of a carriage return. Microsoft's compilers are uniformly happy with the files produced by my editor, and the inconsistent requirements of Digital's compilers are irritating.
The original CBasic-86, which runs under CP/M-86, did not have any graphics support for the IBM-PC. Happily, the folks at Digital Research remedied this omission when they reissued the PC-DOS version. The graphics extension to CBasic is fairly complete and sophisticated on the face of it, but several features described in the manual are not really all there. It comes with quite a few printer and video drivers supporting the Hercules monochrome and the IBM color graphics board, the Microsoft and Mouse Systems mice and 16 printers and plotters.
GSX-86 is designed to be device independent, that is, all graphic output devices like displays, plotters, and printers, appear the same to the applications program. If you decide, for example, to output to a plotter instead of the console, no changes are required in the program code. Getting the proper drivers installed can be a little trick. The manual has been superseded in places by several lengthy READ.ME files on the GSX-86 disk, and if you are so foolish as to try the installation without having thoroughly read them, you will have numerous unpleasant surprises in store.
There are about 25 statements in the graphics module that augment the CBasic language. Some of them have a counterpart in Microsoft Basic: CLEAR/CLS and MAT FILL/PAINT, for example. There are, alas, no statements in the GSX-86 module comparable to PSET, nor does there appear to be a way to set the background color of the display.
The remainder of the CBasic statements are unique and are more oriented towards business graphics than scribble and draw programs. Several statements are useful for making classy graphs. CHARACTER HEIGHT defines the height of letters relative to the length of the Y coordinate. TEXT ANGLE sets the tilt at which the text will print relative to the horizontal. LINE STYLE lets you set the type of line for any subsequent PLOT or MAT PLOT statement. Four standard styles are given: solid, dashed, dotted, and dashed-dotted. ASK STYLE COUNT returns the line styles available on the current open device. Market types, of which there are at least five, can be selected with SET MARKER TYPE. Market height, relative to the current extent of the Y coordinate, can also be specified with SET MARKER HEIGHT. An entire array of X and Y coordinated can be plotted with markers with one MAT MARKER statementf this is obviously very useful for drawing point graphs in a sppedy manner.
The range of the coordinate system is established using a SET WINDOW followed by the X and Y bounds of the corners. This statement can be used to alter the aspect ratio of a device as well. The actual window boundaries can be changed with SET VIEWPORT followed by the corners of the desired window.
The GSX-86 module comes with the source code for several demonstration programs, and numerous other examples are given in the manual. The demos are not very spiffy, especially compared to some of the ones supplied with the PC-DOS disk, but they give a good feeling for what this graphics extension is capable of doing.
Now for the bad news. Listing 1 is a small program I wrote to demonstrate some of the GSX-86 commands. I discovered several more unpleasant surprises when the program was run. First of all, none of the HEIGHT statements is implemented at the present time. This little fact was found in one of the READ.ME files after noticing that SET CHARACTER HEIGHT had no effect on the size of the letters. SET MARKER HEIGHT is in the same boat.
Second, while the screen looked OK, the rendition of this program on my printer is terrible, Figure 2 shows what Digital Research thinks is a decent printout; Figure 3 is an accurate screen dump of the display done with the Prowiter Utilities from Courtrin Enterprises (these excellent programs will be described at a later time). In effect, the device drivers are a little suspect.
Third, if you are so unwise as to turn off the printer while it is printing, the program makes a very ungraceful exit. This is somewhat better than the fourth complaint: you cannot break out of the program at all without resetting the computer. The GOTO X line, while allowing the picture to remain on the screen as long as I wanted to see tilted lines of FOOBARs, also forced me to reset the computer when I got bored with the display.