|
H.5 Using Modules for Further Code Segmentation
|
Let's say we have an
include file containing dozens of routines all
having to do with tax calculations. We might make a
tax module filled
with these common tax routines to make development and maintenance easier.
module taxes
routine calculate_tax with amount, rate, returning tax_due
tax_due = amount * rate
end routine
end module
Code uses this module by including it into the main source code using the
%include directive. Once included, data and routines within the module
are referenced by prefixing their names with the module name and a dot.
taxes.calculate_tax with amount cash, rate tax_rate, returning tax_due total_tax