COMAL AND YOU - For Beginners Only by David Stidolph WHY LEARN TO PROGRAM? The many commercial computer programs available today are more than sufficient for most people's needs. If word processors, spread sheets, and data base managers are all the computer is used for, learning to program would be a waste of time. For some, however, a goal is being able to learn something new... something that can control that mysterious box called a computer. There's nothing like the feeling of accomplishment when you type in your first working program. Also, familiarity with computers and programming helps ease the sense of helplessness most people get when dealing with computers. (How did you feel the first time you got a computerized bill?) This article is for people who have made the decision to not only learn about computers, but to learn programming as well. WHAT IS A COMPUTER LANGUAGE? Computers work with a language of zeros and ones called machine code. This is as difficult to use as it sounds, and few programmers now work directly in machine code. They choose instead to use computer "languages". These range from low level languages like assembly code, where the words merely represent individual machine code instructions, to high level languages which look more like english. Compare the following two programs: CP/M (8080) ASSEMBLY CODE: org 0100h entry: equ 0005h print: equ 09h cr: equ 0dh lf: equ 0ah mvi c,print lxi d,text call entry ret text: db 'I like COMAL",cr,lf,'$' end COMAL: PRINT "I like COMAL" As you can see, the COMAL program is shorter and much more readable. Although the computer will seem to understand COMAL once the language is loaded, the computer itself still only understands machine code. COMAL is itself a machine code program, but instead of letting you do word processing, or other mundane tasks, it allows you to write, edit, and run COMAL programs. Think of the language as an interpreter between you and the computer. This means you don't have to learn machine code - you only have to make sure that the language is in the machine before you can run your COMAL programs. WHY LEARN COMAL? Since BASIC comes with all personal computers today, most people think that it is the best computer language to learn. Not so. BASIC is implemented on so many computers because it is the easiest language to write. It has the fewest commands, and NO definite standard to follow (any arbitrary rules can be forced on it). This means that a BASIC program written on one computer may NOT run on any other computer. BASIC does, however, have one good feature; the ability to type in a short program and see it execute as soon as you type the word RUN. No text editors or elaborate compiler commands (needed in most other high level languages like Pascal, Fortran or Cobol) are necessary. This makes BASIC seem like a easy-to-learn language for everyone. COMAL started with this idea of interactive work with the programmer, then added to it. Added were things like the structured code of Pascal, the graphics of Logo, and a few tricks of its own. COMAL is now the language taught in the schools of 5 European countries. COMAL is easier to learn than BASIC, and teaches the idea of structured programing necessary to using modern computer languages. HOW DO YOU GET COMAL? CP/M COMAL is available in the United States from the COMAL Users Group, USA Limited, 6041 Monona Drive, Madison, WI 53716 for under $50. This version runs on CP/M computers such as the Kaypro, Epson, and Commodore 128. It must be installed for each computer, but data files are included to help install COMAL for most popular CP/M computers. Once COMAL is installed, programs which don't use machine specific items, such as color on the c128, can run on any other CP/M system as long as it also has COMAL installed. Only CP/M COMAL will be discussed in the rest of this article, but disk based COMAL for the Commodore 64 isavailable from most local User Groups or may be ordered directly from COMAL Users Group for under $20. There is also a COMAL cartridge for the 64, and versions of COMAL running on the IBM. Once you have CP/M COMAL, you must run the INSTALL.COM directly from CP/M. Follow the directions that come with CP/M COMAL to install COMAL correctly for your computer. Once COMAL is installed, you never need to install it again, (unless you change computers). Then to enter COMAL, simply type the word COMAL in response to the standard A> prompt. You are now ready to run COMAL programs. WHAT DO I DO WITH COMAL? The purpose of COMAL is for YOU to learn how to write readable programs, and one way to learn is to first look at other peoples' work. I am going detail certain commands here so that you can do just that. The commands will be listed in UPPERCASE, but type them in as unshifted letters. CAT This command will show you what is on the disk drive. The disk drive sends the disk DIRECTORY (that's what it is called) to the computer, and COMAL prints it on the screen. The number of free bytes on the disk are also displayed. DIR may be used in place of CAT by those who are more comfortable with using it to obtain a directory. COMAL will not erase the program in memory while showing a directory of a disk. If you happen to have a two or more drives, you can choose between them: cat "a:" (This is for drive A) cat "b:" (This is for drive B) LOAD Once you know what is on the disk, you can load COMAL programs into memory with this command. The following is an example of loading a program called filename: load "filename" If you don't want to type in the three character extension, the system will insert .SAV as a default. LIST Once a COMAL program is in memory, you will want to be able to see it. The command LIST will do just that, it will list the program to the screen. The program is listed one screenful at a time. Hit the spacebar to see the next screenful, or the key to stop the listing. The return key can be used to see one more line at a time. You will notice that each line has a number in front of it. These are called "line numbers" and COMAL uses them to keep track of the order of the program lines. The order goes from low (1) to high (9999), and you can use any line number between them. The LIST command can also be used to show just part of a program. The following are some Examples to do just that: list (all lines) list 100-500 list 100- list -500 list procname (list named procedure) RUN When the program you want has been loaded into memory, you start the program with the command RUN. The computer does a quick scan of the program to make sure it seems correct, and starts executing with the first line of the program. If an error occurs while the program is running, the program will stop executing, and COMAL will print the line number it is having the trouble with, and what the problem is. MAKING ERRORS There is a very good chance that you will make typing errors while trying these commands. COMAL checks each line you type for errors, and if it cannot understand what you typed, it will stop and give you an error message. It might go out to the disk drive and get the error message, or it might just print the message itself (that depends on whether you have error messages in memory or not). If you get an error, COMAL will put the cursor on the part of the line it is having trouble with so DON'T PANIC. Just make the correction and press the RETURN key again.