In most cases the best way to pass information from one program unit to another is to use the procedure argument list mechanism. This preserves the modularity and independence of procedures as much as possible. Argument lists are, however, less satisfactory in a group of procedures forming a package which have to share a large amount of information with each other. Procedure argument lists then tend to be come long, cumbersome, and even inefficient. If this package of procedures is intended for general use it is quite important to keep the external interface as uncomplicated as possible. This can be achieved by using the procedure argument lists only for import of information from and export to the rest of the program, and handling the communications between one procedure in the package and another with common blocks. The user is then free to ignore the internal workings of the package.
For example, in a simple package to handle a pen-plotter you may want to provide simple procedure calls such as:
|Initialise the plotting device
|Set the scaling factor to F.
|Move the pen to position (X,Y)
|Draw a line from the last pen position to (X,Y).
These procedures clearly have to pass information from one to another about the current pen position, scaling factor, etc. A suitable common block definition might look like this:
COMMON /PLOT/ OPENED, ORIGIN(2), PSCALE, NUMPEN LOGICAL OPENED INTEGER NUMPEN REAL PSCALE, ORIGIN SAVE /PLOT/
These specification statements would be needed in each procedure in the package.