5.4 Program Documentation
Documenting a program is the process of mixing text (com-
ments) and code in a way that helps make the program more
understandable. Program documentation does not affect the
way a program executes.
You can add comments throughout a program; however,
programs that are neatly structured need fewer comments.
You can clarify your code by doing the following:
.
Using meaningful variable names
.
Including sufficient white space
.
Indenting your program lines according to the structure
of your code
A comment field starts with an exclamation point ( ! ) and
ends with a carriage return. The following example con-
tains both comments and program statements. Any text that
follows an exclamation point is ignored.
PROGRAM sample
!+
! Require that all variables be declared
!-
OPTION TYPE = EXPLICIT
!+
! Set up error handler
!-
WHEN ERROR USE Error_routine
!+
! Declarations
!-
.
.
.
END PROGRAM
You can also mix comments and code on the same line. For
example:
DECLARE &
INTEGER &
Print_page, ! Current page number &
Print_line, ! Current line number &
Print_column ! Current column number
All text between the exclamation point and the carriage re-
turn is ignored, with one exception: the ampersand is still
recognized. This is a continuation character that specifies
that a single statement is being continued on the next line.
Only spaces and tabs are valid between the ampersand and
the carriage return.