Classic Computer Magazine Archive CREATIVE COMPUTING VOL. 10, NO. 10 / OCTOBER 1984 / PAGE 191

IBM images; MegaBasic: Rolls Royce or Subaru? (evaluation) Susan Glinert-Cole.


Billed as the Rolls Royce of Basics, this language is a product of the American Planning Corporation. It features direct addressing of one megabyte of memory, a semi-compiled run-time package for zippy execution and a Forth-like language extensibility. MegaBasic edges into the domain of block structured languages like Pascal by supporting recursion and parameter passing by value or address. Like Morgan Microcomputing's Professional Basic, MegaBasic allows program lines, functions, and procedures to be referred to by name. Up to 64 separate "packages," which can be used either as separate programs or as overlays, can coexist simultaneously in memory.

The version reviewed here is 4.1, which requires an 8086/8088 processor, 128K, one disk drive, CP/M-86, MPM-86, TurboDOS, MS-DOS, or PC-DOS. Although the manual talks about several utilities that were supposed to be on the disk, only one was actually present on my copy: a program size compressor.

Numeric representation is Binary Coded Decimal (BCD) floating point with a range of -10.sup.63 to 10.sup.63. BCD represents decimal values up to the precision limits exactly. This eliminates the "missing penny" problem resulting from round-off error; BCD is especially suited, therefore, for financial calculations. APC supplies both 8-and 14-digit precision versions of the MegaBasic system on the diskette. Unfortunately, there is no way to use any numeric representation other than BCD that I could find. Integer freaks will be disappointed.

The documentation is a handsome 304-page manual with a table of contents, index, and (bless their hearts) tabbed section dividers. Unfortunately, it is inadequate considering the tremendous number of new functions and statements introduced, not to mention a different editor. Very few examples show actual command usage in proper context, although there are several programs on the disk to study. This wouldn't be a big program if the syntax were identical to IBM's, but there are subtle differences which you must figure out by trial and error. The documentation is also out of sync with the disk: files mentioned in the manual didn't exist, and several files on the disk were not mentioned. It didn't take too much to figure it out, but I expect the documentation to save me the trouble of having to do that. The manual needs a thorough overhaul before it can be given a passing grade. Pros

I'll start with the good news: MegaBasic has an impressive range of new functions, statements, and low level system interface tools.

In addition to the usual string functions, like LEN(X$), CHR$(X), and STR(X$), MegaBasic provides a full complement of convenient extras. TRIM (X$) returns the string X$ stripped of all leading and trailing spaces. REV(X$) returns X$ with the characters in reverse order. If you prefer a more exotic order, RESEQ(X$,N) will reorder X$ depending on the value of N. The returned sequence begins with the first byte of X$, followed by the Nth byte, followed by the Nth byte after that and so on. The process wraps around to the beginning of the string and continues until all the bytes have been accessed. The manual points out that this function is useful for restructuring a string from a row/column order to a column/row order and vice versa, sector translation tables for operating systems, and playing card games. MIN(X&,Y$,...) returns the minimum string expression value listed; MAX(X$,Y$,...) returns the maximum.

The math functions available are comparable to PC-Basic, with several extras. One unusual one is POLY(X,A*,D), which returns the polynomial evaluation of X using coefficient array A* containing D+1 coefficients, where D is the polynomial degree.

A new data definition statement included in APC is ON ...RESTORE (line list). This statement is a member of the ON ... GOTO family, permitting multiway branching based on some boolean value. In this case, the line list is a sequence of line numbers that contain data statements. A data read pointer is set to the first data statement on or after the line number selected in the branch, allowing data selection based on a multi-way decision.

Another valuable statement is LOCAL (variable list). LOCAL creates temporary simple variables which can be used within a subroutine, user defined function, or variable. Arrays cannot be used as a LOCAL variable. This would allow you, for example, to declare X in the body of the main program, and use X within a subroutine, without affecting the value of the original X. Variables are not usually permitted scope in Basic, although scope is a regular feature of structures languages.

Two statements are used to create functions and procedures that will be "shared," e.g., available, from outside the main program. This is similar to the assembly language attribute PUBLIC. Functions, whether shared or not, can be multi-line, and do not have to begin with FN.

The segmentation and overlay scheme of MegaBasic is implemented by eight new statements. DEF SHARED (function or procedure) and DEF SHARED DATA (list of variable names) are used to define shared functions, procedures, and variable names. INCLUDE (list of package names) will bring a list of program files containing packages into memory for later execution. LINK (program name) [(common variables)] will terminate the current program, erase it from memory, load the program specified by the string expression, and execute it. Programs can be dynamically merged during execution with the MERGE (program name) statement. If, for some reason you want to remove program lines after they have been executed, you can do this with the DEL (line number--line number).

A wealth of file and device I/O function, which are sorely missing from PC Basic, are included. DIR$ returns file names, one at a time, from the directory, permitting sequential file processing. FILE(S$) will look up the file S$ in the directory and return a 1 if present, a 0 otherwise. FILEPOS(X) returns the current position of the file pointer from the beginning of the open file X. FILESIZE(X) returns the file size in bytes or, if placed on the left side of an assignment statement, will set the file size to the number of bytes on the righthand side. SPACE(X) returns the number of bytes available on the disk drive.

The program appears robust; no matter what sort of strange commands I issued, MegaBasic coped without a single lockup. The error messages were not always helpful, but by and large, it was relatively easy to figure out what the program was. Cons

And now folks, for the bad news. As already stated above, the documentation is inadequate. To begin your journey in the Rolls, you are instructed to type BASIC. This results in a FILE NOT FOUND error; there is no file on the disk with such a simple name. Instead, the programs are called mysterious names like MSDBASO8.EXE. A little poking around in the manual will shed some light on the purpose of these files, but it is a bit rude to have the door handle come off in your hand.

The editor in MegaBasic is reminiscent of, but not nearly as good as, EDLIN. Its basic philosophy is very primitive line editing. This is performed by a thoroughly un-mnemonic group of CTRL-letter keystrokes, some of which do not perform as described in the manual. Editing is really weird. You can't move backward and forward on the line; the cursor keys are disabled. Instead, you can enter a line (and do destructive backspacing), or copy an old line letter by letter, word by word, or entirely. Although the manual says you can move backward by word with the CTRL-W command, I found this did a destructive backspace by word (the manual says this is done with CTRL-T). Inserting characters in a line is signaled with a CTRL-Y, which puts a left angle bracket in the line. You enter the desired letters, and emit another CTRL-Y (putting a right angle bracket in the line), when done. Although I entered only short programs, I found editing by this method absolute agony.

In addition to these line commands, MegaBasic has global search move, copy, and replace facilities. There is some minimal syntax checking when a line is entered; some syntax errors are caught, but others aren't detected until the program is actually run. The superb syntax checking of Professional Basic spoiled me some. After all, IBM Basic doesn't have dynamic syntax checking. I guess I found the half-hearted attempt of MegaBasic more irritating than no error checking at all.

Another problem, which may be due to the poor documentation, is that there doesn't seem to be any way to list a program to the printer. Listing 2 was produced by good old Shift-PrtSc. One other point: no sound (not even the primitive but useful beep) or graphics statements are currently implemented.

Listing 1 shows the same PC-Basic Sieve program as last month. This was loaded directly into MegaBasic as an ASCII file. MegaBasic did some partial conversion to its own syntax, (STEP was changed to BY, for example). Other syntax incompatibilities were left for me to change manually (the abbreviated REM statement, for example). After all this, the program ran incorrectly, because of the way MegaBasic handles GOTOS within an IF...THEN loop. I couldn't figure out from the manual how to do it any other way than the kludge in lines 190 and 195. After all this effort, the program times were very disappointng (see Table 1). MegaBasic is not for programmers who want to hear the sound of screeching bits and see smoke issuing from the 8088 during execution.

In short, MegaBasic isn't exactly a Roll Royce. It reminds me more of my Subaru. Bristling with bells, whistles, and knobs to twiddle, it is slow to accelerate, dependable, and runs like a clock. Miniatures Vignettes

If your IBM PC is early vintage, you can give it a silicon facelift with a modest expenditure of $30 for a new ROM chip. You can tell if your machine is showing its age if its serial number is 0300960 or lower and the BIOS date is 10/19/81 or earlier. The ROM date can be checked with a four-line Basic program: 10 DEF SEG = &HFFFF 20 FOR X = 5 TO 15 30 PRINT CHR$(PEEK (X)) 40 NEXT X

The new BIOS is required if you want to install an expansion chassis or hook your computer into the IBM Cluster. A new BIOS chip is supplied with these two hardware extensions, but you might find some piece of hardware that requires the update. It is available from IBM as part number 1501005; the kit includes a chip puller, instructions and, of course, the chip itself.

If you are tired of the same old black and white in the high-resolution graphics mode, one short instruction will change the foreground color to any of 16 colors. The instruction is: OUT &H3D9, COLOR For example, the statement OUT &H3D9, 2 will show a black background and a green foreground display.

In keeping with the above short programs, Chris Friedl contributed an eight-line arcade game written in Basic (see Listing 3). This is one of the niftiest tour de forces I have seen in a long time. I have played many games with a code size a thousand times less fun. His description follows. Astro

Astro was developed by Ascalon Software in an attempt to find out just how small a game program could be. Astro was first programmed on a TRS-80 and consisted of eight lines of coding each with fewer than 64 characters per line.

The object of the game is to dodge the asteroids while trying to pick up the fuel pods (*). The player controls the ship by using the number keys 1, 2, and 3. Pressing the 1 key will cause the ship to move left. It will continue to move left until another key is pressed, or the ship is a short distance from the left side of the screen. The 2 key stops the sideways movement of the ship, and pressing 3 causes the ship to move right.

One point is given to the player for each unit of fuel expended. In addition to 10 points for picking up a fuel pod, the player receives an extra 25 units of fuel.

Hint: Remember that the PC has a keyboard buffer. Holding down a key for any length of time starts to fill up the buffer. If you press another key immediately after holding down a key, the new direction command will be delayed. This could cause you to crash or miss an opportunity for extra fuel. For best response just tap the key you want and then release it. Feedback

Anyone wishing to pay me a timely compliment can do so in the Compuserve IBM PC Sig or Creative's own Sig. I am now tuning in several times a week.

Products: MagaBasic (computer program) - Innovations