A simple Comal program is set out in a LINEAR structure. That is it starts at the beginning and carries on to the end, with no detours or breaks. This linear type of program is useful to learn the basics of programming, but does not lend itself to more complex problems.


The most important addition to the basic linear structure is the Procedure.

A procedure can be described as a sub-program or a part-program. It can be thought of as a black box, which will do the same job again and again, and only has to be put in the right place for it to work. (Click on the link to procedures now if you wish more information, or wait until you have finished this section.)

If a certain complex task has to be performed again and again, then a procedure would be placed wherever the task needs doing. This saves having to write the same code again and again.

The structure of a Comal program (at least for Std.Grade) is composed using Loops, Conditional statements, Read & Data statements, and Arrays, and these components are packaged into procedures, which can be reused many times if required.

The above mentioned components are dealt with in more detail in their respective sections, but a brief description will help you before you go into the details, especially if you are new to programming.


Loops are used when you want something to happen again and again. For example, if you want to ask a question more than once, or to give the user 3 tries to guess a number. There are many different loop structures, but we will only be looking at 3 of them: FOR loop, REPEAT loop and WHILE loop.

Conditional Statements

Conditional statements are commonly referred to as IF statements, and are used to allow the program to "choose" different actions according to the conditions you (the programmer) set out. The conditions may depend on INPUTS or from internal conditions developed by the program. (There is a special type of conditional statement called a CASE statement, used when you need to make one choice from a large selection of options.)

Read and Data Statements

READ & DATA statements are structural components used in automatic handling of data. These can be used to set up names, addresses for forms or print outs, but really become useful when putting data into arrays.


ARRAYS can be thought of as tables which hold data. Because all the data is held in tables, it becomes easy to manipulate the data. For example, searching and sorting data becomes possible, comparisons between different sets of data becomes possible, and storage of large amounts of data would really be impossible without arrays. (Databases are simply collections of arrays.)

All of these structural components need to be put together in the correct logical sequence for the program to work, and for this we need to plan.

All complex tasks need careful detailed planning and implementation, and programming is no exception. There are simple steps to follow to make the process easier, and these will be explained in the PLANNING section.