Revision [11644]

This is an old revision of KeyPgPpmacro made by JeffMarshall on 2007-11-10 09:14:45.



Preprocessor directive to define a multiline macro

#macro macro_name( [ param1 [, param_list] ] )
macro body

#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 KeyPgPpifdef #ifdef and KeyPgPpifndef #ifndef preprocessor conditionals can test if macro_name exists or does not exist.
The KeyPgPpundef #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.

'' macro as an expression value
#macro Print1( a, b )
  a + b

Print Print1( "Hello", "World" )

'' Output :
'' Hello World!

'' macro as multiple statements
#macro Print2( a, b )
  Print a;
  Print " ";
  Print b;
  Print "!"

Print2( "Hello", "World" )

'' Output :
'' Hello World!

Differences from QB:
See also:
Back to Preprocessor
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki phatcode