Comal | Everygamegoing

Personal Computer News


Published in Personal Computer News #077

Comal 80 is ace for structured programming on the C64, says Barry Miles.

Comprehensible Comal

Comal 80 is ace for structured programming on the C64, says Barry Miles

Comal 80 is a cartridge which will be released in the near future by Commodore for the C64. Comal stands for Common Algorithmic Language and is designed to be better than Basic or Pascal by combining the best features of both of them, and being extremely user-friendly into the bargain.

In Use

When the language is in the machine, you still have 40K of memory available for your Comal program. In addition, some 12K is available for use by machine code programs.

Comal is the Basic to end all Basics. It makes teaching yourself programming an easy and enjoyable experience. It scores highly compared to other languages because of its very strict adherence to the principles of structured programming and its amazingly helpful error correction and detection features.

No stone has been left unturned to make this language extremely easy to learn. Not only do you write your programs quickly, but they will be running correctly far sooner than with an unstructured Basic. This is made possible by a pre-pass system in which the syntax of every statement you have entered is checked and errors are pointed out in detail.

A truly structured language such as Comal imposes constraints and reduces the liberty with which you can plan and design your programs. However, it also stops you from concocting such convoluted code that no-one but yourself can understand it.

Comal, being pre-compiled, is an extremely fast language in operation. Searching 1,000 strings to see whether any one of them contains a particular sub-string is 1,000 times faster with Comal than it is using the Commodore 64's normal Basic with the MID$ command.

The cartridge contains no less than 11 separate modules which can be invokved with the command USE, so you might say USE GRAPHICS in order to invoke the graphics pack.

When the C64 was designed, no effort was made to enhance Basic to include appropriate graphics keywords. With Comal's interrupt-driven sprites you can set sprites in motion, carry out some other activities in your program while the sprites continue to move, and then interrupt their movement at will. This means that writing games in Comal will be a good substitute for writing games in assembly language and the results will be almost as fast. Similar interrupt-driven treatment is also given to the sound commands. Sound routines can be written so music plays while the rest of your program is running.

Programming in Comal is pure delight. The AUTO command produces automatic line-numbering, but line numbers are always four digits long, so 10 becomes 0010. As you write your program, the interpreter or compiler works in such a way that indentation of appropriate structures is automatic. The indentation provided by Comal is more powerful than it seems because, by looking down a listing, it's very easy to see whether or not you've closed off the structures you've started. Also, the language will tell you that you have failed to complete a particular construction and will display the offending line.

Reference to the manual is infrequent because the language itself will tell you where you are going wrong. Editing commands include RE-NUMBER, FIND, SEARCH, REPLACE, and DELETE, and you can delete or list procedures by name.


A 'procedure' is a piece of code which carries out a particular function. It has one entry point and one exit point only. In Comal, procedures can either be open or closed. In the case of a closed procedure the variables in it are local to that procedure. The significance of this is that you can import procedures from your library of routines, or from someone else's, knowing that there will be no clash of variable names. The process of building up your program then becomes one of joining together a series of procedures from various sources to form one major procedure which carries out the task.

This greatly facilitates structured programming using the top-down method. The top-down methd defines the problem to be solved as a series of tasks. Each task may be divided into a group of sub-tasks and so on. You continue this process of 'stepwise refinement' until the list is so detailed you can simply write the code to do each part.

Translated into the Comal environment this implies writing your main program as a list of procedure names. You then write the procedures and test each one. Once the testing is satisfactory, you can put all the procedures together to make the program.

It is said that the single most effective enemy of good programming is the GOTO command. Tracing the flow of events through a program involving many GOTOs is frustrating. Comal avoids this by calling up blocks of code by the name of the procedure and by parameter passing.

IF...THEN, ELSIF and ELSE are provided, as are full looping structures. DO WHILE, DO UNTIL and a CASE structure have been borrowed from Pascal. Armed with these programming tools it's extremely simple to program in a straightforward manner so that anyone reading the program can see exactly what's involved.


Comal revolutionises the Commodore 64. It makes learning structured programming easy and the speed with which the graphics, sound and other parts of the language operate implies that machine language will rarely be required. And if the price is right this package deserves to be highly successful.

Barry Miles