#MACRO...#ENDMACRO
Preprocessor directive to define a multiline macro
Syntax:
#macro macro_name( [
param1 [,
param_list] ] )
macro body
#endmacro
Description:
#macro defines a function like macro where macro body may span multiple lines.
Parameters supplied to the function like macro are substituted where they occur in the macro body. The entire macro body is substituted where ever macro_name appears in the source code. The number of parameters supplied to a macro must match the number of parameters in its #macro definition.
The
#ifdef and
#ifndef preprocessor conditionals can test if
macro_name exists or does not exist.
The
#undef preprocessor directive will undefine a macro so that it may be redefined with another definition.
Macro substitution can be checked by using the -g -r switches. The compiler doesn't erase the intermediate .asm file where the code actually sent to the compiler can be seen close to its translation into assembler.
Examples:
'' macro as an expression value
#macro Print1( a, b )
a + b
#endmacro
Print Print1( "Hello", "World" )
'' Output :
'' Hello World!
'' macro as multiple statements
#macro Print2( a, b )
Print a;
Print " ";
Print b;
Print "!"
#endmacro
Print2( "Hello", "World" )
'' Output :
'' Hello World!
Differences from QB:
See also:
There are no comments on this page. [Add comment]