Creating and Using Macros [ VIRTUOSO CODE GENERATOR Reference Manual ] MPE/iX 5.0 Documentation
VIRTUOSO CODE GENERATOR Reference Manual
Chapter 4 Creating and Using Macros
A macro is a reusable unit of code which can be invoked with a set of
parameters. Thus, a single macro can be used to solve different problems
by varying the parameters. Typically, a macro is a high level statement
which results in generation of multiple lines of code.
Macros can be used for common subsystem calls, providing easier
programming access to files, forms files, and databases. This simplifies
coding and reduces the number of errors. A macro should solve a specific
need, such as opening a database, reading the data from a form, or
retrieving relationship occurrences from the System Dictionary.
Macros consist of a #macro construct, Virtuoso statements and user text,
and the #endmacro which defines the end of the macro. The Virtuoso
statements and user text lines within the macro are the same as any other
Virtuoso source code and can include calls to other macros. Macros are
defined in Source Macro Files. A single file can contain many macros.
Source Macro Files must be processed by the Virtuoso Code Generator into
Processed Macro Files. These are binary files which can be accessed by
the generator. The generator uses these binary files when it processes
Virtuoso source which invokes a macro in the Processed Macro File.
The following are characteristics of macros:
* The macro performs a function or action. The macro performs one
specific task and also includes parameter setup and possible error
handling. For example, a macro might close multiple databases and
provide error handling for unusual conditions.
* The macro is generic. The macro uses keywords instead of hard-coding
the names of modules, databases, data sets, and other specific
information. This information should be passed into the macro. If
desired, it may be stored in the System Dictionary and retrieved at
generation-time.
* The macro provides defaults, whenever possible, to reduce the amount
of specific information required.
* The macro performs a function or action which is commonly used, for
example, common TurboIMAGE or FORMSPEC procedures.
* The macro adheres to and aids in implementing programming standards.
* The macro is easy to understand and maintain.
* A productivity gain is realized when programming with the macro.
Using macros has many advantages. Programs can be quickly written with
the aid of macros. Also, the amount of time spent in testing can be
reduced because the code generated by the macros has already been tested.
Well-designed macros help to establish and implement your organization's
standard programming practices.
Refer to the Virtuoso COBOL Sample Library Reference Manual (30426-90001)
for examples which use the macros and models.
MPE/iX 5.0 Documentation