From GridLAB-D Wiki
Jump to: navigation, search

Macros are used by the GridLAB-D GLM loader to control how the GLM is interpreted. All macros are introduced by a hash mark, e.g.,

#if test
// conditional 
#endif
#binpath path
Define the path to search for executables.  DEPRECATED 
#debug string
Prints string when debugging is enabled.  New in 4.0! 
#define variable=value
Define new macro variables.
#endif
End an #if, #ifdef, or #ifndef block.
#else
Open an alternative block after an #if, #ifexist, #ifdef, or #ifndef block.
#error message
Force the GLM loader to print an error message and stop.
#if test
Open an #if block.
#ifdef variable
Open an #ifdef block.
#ifexist file
Open an #ifexist block.
#ifndef variable
Open an #ifndef block.
#include [using(name=value[,...])] file
Include another GLM file.
#incpath path
Define the path to search for include files.  DEPRECATED 
#libpath path
Define the path to search for library files.  DEPRECATED 
#option command-option
Runs a command option Template:NEW30
#print message
Print a message.
#set variable=value
Set global variables.
#setenv variable=value
Set environment variables.
#start file-name
Start a program asynchronously.
#system command
Execute a command in an operating system shell.
#warning message
Display a warning message and continue loading the GLM file.
#wget url
Download a web resource from the specified URL.  New in 4.0! 

Variables

Macro variables are expanded in-line while the GLM file is being loaded, so expansion is immediate. The normal syntax for defining and including a macro variables is

#define my_class=test
class ${my_class} {
  // declarations
}

Macro expansions will expand macro variables, global variables, and environment variables.

See also