##macro/##endmacro [ VIRTUOSO CODE GENERATOR Reference Manual ] MPE/iX 5.0 Documentation
VIRTUOSO CODE GENERATOR Reference Manual
#macro/#endmacro
Designates the beginning and end of a macro.
Syntax
#macro macroname [keyword1=Keyword-Info1 &
# keyword2=Keyword-Info2 ... ]
.
.
#endmacro
Keywords
macroname is the name of the macro. This macro name must be
unique for the Processed Macro File and cannot be a
reserved word. The macro name can be up to 32
characters long.
keyword1 is the name by which a parameter will be known in the
macro body. The keyword must be unique for the macro.
There can be up to 30 unique keywords per macro.
keyword-info1 is a positional list of values that specify the type of
keyword and the default value, if the keyword is
optional. The syntax for keyword-info is:
(Keyword-Type, Default-Value) or
(Keyword-Type) or
Keyword-Type
Keyword-Type can be either STRING or NUMERIC. It
describes the data type of the value that will be
assigned to the keyword when the macro is invoked.
Default-Value is the default value of the keyword. If a
default value is not specified for the keyword, then the
keyword is required when the macro is invoked. If a
default value is specified, then the keyword is optional
when the macro is invoked. In this case, the keyword is
assigned the default value if another value is not
specified at macro invocation. Default values are
limited to 43 characters. Note that if Keyword-Type is
STRING, Default-Value must be enclosed in quotes (" ").
If Keyword-Type is NUMERIC, then Default-Value must not
be enclosed in quotes.
Description
The #macro/#endmacro constructs are used to designate a portion of
Virtuoso source code as a macro. The #macro construct is known as the
macro header. It defines the parameters which are to be passed to the
macro. The #endmacro construct defines the end of the macro. The
statements between these two constructs are the macro body. The macro
body can consist of Virtuoso constructs, calls to other macros and user
text, just as in any other Virtuoso source code. The #macro construct is
used only in source macro files; it does not appear in other Virtuoso
source files.
When the generator is run with MP=ON to process the source macro file, it
checks for matching #macro and #endmacro constructs. The generator will
issue an error if it encounters an unexpected or unmatched #macro or
#endmacro construct. No other syntax is checked when running the
generation with MP=ON. Other syntax checking is done when the macro is
invoked.
When naming macros keep in mind that the first 8 characters of the macro
name are displayed in columns 73-80 of the output file when the trace
parameter of the #option construct is ON. Keeping the first 8 characters
of the macro names unique will help you identify macros in the generator
output file and reduce the time spent in debugging.
Nesting of macros is allowed, but remember that the nesting limit is 40.
That is, there cannot be more than 40 nesting levels in existence at one
time. This includes nesting of #for/#endfor, #if/#endif, #include,
#block/#endblock, #entry/#endentry and macros.
For more information on creating macros and on the requirements for
creating a macro, refer to Chapter 4.
Examples
The following is an example of using the #macro and #endmacro constructs.
For more examples, refer to Chapter 4.
#macro DBDelete image-database=string &
# image-dataset=string
PERFORM
MOVE "!image-dataset" TO DB-SET
MOVE MODE1 TO DB-MODE
CALL "DBDELETE" USING !image-database!-DATA
DB-SET
DB-MODE
DB-STATUS
END-PERFORM
#endmacro
In the above example, the #macro construct designates the beginning of
the macro header. The DBDelete macro header consists of two lines. Note
that the #macro line is continued to a second line using the "&" sign.
The macro body is the contents between the #macro and the #endmacro
statements.
MPE/iX 5.0 Documentation