The Commander – A Command Extension Facility
Jim Butterfield, Associate Editor
The Commander is a 4K ROM for PET/CBM computers with 4.0 BASIC, which extends the capabilities of BASIC programs. It's a little different from editing "enhancers" and is worth a few extra comments.
There are essentially two types of BASIC-helper programs: editing and runtime.
Editing packages help you prepare a program. They may give you ease of program entry, renumbering, search and change capability, and other features to help you build the program and spot errors.
Once the program is complete, the editing package has done its job. The completed program will now run by itself. If you have prepared a program using BASIC-Aid, POWER, Sysres, or a similar package, the final program can run on any PET/CBM – even ones without the editing facility.
In other words, if you give a friend a copy of a program that you've written using one of the super-editors, he or she will be able to load it and run it. There's more: since the final program runs without using the editor, it will run at full BASIC speed.
Runtime packages help the program run. This means that everyone who wishes to run a program containing a runtime package feature must also have the package. A software house which created products using the Commander, for example, would need to specify that all purchasers of these packages must also have the appropriate runtime package.
A potential difficulty of runtime packages can be that programs using them may slow down, due to the extra overhead. Many packages use a "wedge" technique that slows everything down – sometimes a little, sometimes a lot. The Commander doesn't have this problem: its functions are invoked only when the program calls them in with a suitable SYS command.
An editing package tries to solve the question "What's missing from the machine's regular editing features?" A runtime package addresses the question "What's missing from BASIC?"
People may have different preferences and thoughts about what's missing, based on their experience with other BASICs and other languages. The Commander has chosen these:
PRINT USING: Formats a floating point variable into a string with a specific length and format;
WINDOW: Clears a specific area of the screen, on either 40–or 80–column machines;
FRAME: Prints a screen message, enclosed in a frame, for the user's benefit;
INSERT, APPEND, DELETE: Allows a program to be changed as it runs;
COM LITERALS: Repacks strings to help the above change features;
OVERLAY: Allows a program to call another program to continue the run;
RETURN CLEAR: Cancels all GOSUB and FOR/NEXT loop status;
COMPUTED GOTO: Allows a GOTO address to be calculated;
MAT PRINT#, MAT INPUT#, MAT INIT, MAT ZER: Allows arrays to be saved, recalled, and cleared quickly;
ENHANCED GET, STRING: Allows more powerful INPUT from keyboard or file.
Invoking The Commands
Using the Commander, you would invoke these functions with a SYS command. First, you'd be expected to set up variables which set the range of activities needed. For example, to delete lines 300 to 400 in a running program, you'd type in these lines:
360 BL = 30(Begin Line 300) 370 EL = 400(End before Line 400) 380 GT = 400(When complete, GOTO 400) 390 SYS 40006(Delete)
The SYS may be different, depending on the particular ROM chip fitted. When the program reaches line 390, it will delete all lines from 300 to just below 400 – including the above lines – and will continue running at line 400.
This is astonishing. We've made a significant change in a running program and yet the program can continue running, complete with live variables. We can't do that even if we stopped the program and made a change or deletion: our variables would disappear.
The Commander allows a program to modify itself as it runs, without loss of variables. That's amazing. It's also dangerous, and some computer scientists might argue that it's bad practice. The argument runs like this: BASIC is intended to be a "fixed framework" program, and all BASIC programs should be written that way. Selfmodifying programs are foreign to BASIC: but with the Commander, you can have them.
Chaining And Such
Users may see this feature as one of the great conveniences of the Commander. Chaining and overlaying are rather complex activities on a PET/CBM. The Commander gives you shortcuts which make the job easier. The OVERLAY command, for example, says "throw away the old program and variables and start the new one I have named." INSERT, APPEND, and DELETE commands, on the other hand, allow the user to modify or replace the running program with new programming and keep going, complete with variables in place.
The system takes care of most activity needed to preserve variables (using what the manual calls a "Common" facility), but one kind of variable needs a little extra work to preserve: "literal" strings. This is the type of string defined by a statement such as X$ = "PASS 1". The string is used where it lies in the program line; deleting the program line will make the string disappear. A special Common command may be used to move this kind of string into a safe place.
The PRINT USING facility doesn't print; it just formats numbers into a string, from which you can print them. It has a reasonable complement of formatting facilities – punctuation, commas, etc. –but doesn't include advanced features such as floating dollar signs, asterisk fill, or special negative symbols such as "CR" or parentheses.
A small deficiency of the PRINT USING feature on the package I tested was that numbers are not rounded; they are truncated. This could cause problems if the user doesn't watch for it, since a financial number such as 6.35 might be held within the computer as 6.34999999; this would truncate to 6.34, which is wrong. The user can cover this possibility by adding .005 to the value before calling PRINT USING: but it would be better if the Commander covered this case.
Odds And Ends
The FRAME and WINDOW commands allow nice screen displays to be generated easily. CONVERT to ASCII can be useful to interface to standard ASCII (non-Commodore) printers, if the interface hardware doesn't do it already for you. RETURN CLEAR allows you to exit from subroutines and loops in an unorthodox manner, and computed GOTO works conveniently and well. The programmer should use these features with caution, since they could lead to "cute" programming that may cause debugging problems.
There are two special I/O commands. STRING INPUT allows information to be input from disk, including punctuation such as commas or colons; it's an improvement over BASIC, which trips up on these. There are MAT PRINT# and MAT INPUT# commands to save and recall arrays; these are written and read in a highly compacted form to save time and disk storage space. Files so written are not strongly compatible with other programs; you would have considerable difficulty getting them back with a conventional set of INPUT commands, so you'll want to use MAT INPUT# to do the corresponding input job.
The other MAT commands are a simple set of array commands which allow you to clear an array quickly (set to zero or null string). There's a gimmick which might be useful: you don't have to clear the whole array, since you can start partway through and clear from that point on.
The Commander comes in two versions. Version 11–4 goes into socket UD11 (or UD4 on older machines) and has SYS addresses in the range 40000 to 40110; version 12–3 is for socket UD12 (or UD3 on older machines) and has SYS addresses in the range 44000 to 44110. If your computer already has one ROM chip in place, you can order the version which fits your blank socket; otherwise, it doesn't matter.
Documentation is complete, but a little fuzzy. The manual will seem cryptic to the beginner –for example, the Common facility is described in detail even though in most cases it's automatically invoked when needed. However, the Commander comes with a demonstration diskette, which serves as wonderful documentation. The user is invited to stop the demonstration programs and invoke various features. By using this diskette, the user will enjoy a wellpaced training experience.
Programs written using the Commander will always need the Commander. You must be prepared to live with this; but once you do, you'll find a host of dynamic features at your fingertips.
Many of the features are useful; and the capability of having a program modify itself while running is exceptional. Using the Commander, there are new possibilities for your system.
$70, including manual and demo diskette
Specify ROM expansion socket, and 4040 or 8050 demo diskette
Commander Systems Inc.
4505 Jackson Street
Hollywood, FL 33021