Miscellaneous Macro Functions
Miscellaneous Macro Functions
These function don't fit neatly into other categories, but are useful.
DumpMacroState (hbufOutput)
This function appends text describing the current state of the running macro to the buffer hbufOutput. The macro state consists of the values of all variables, and the execution stack. This function is useful when debugging macros.
GetProgramEnvironmentInfo ()
Returns a ProgEnvInfo record, which contains information about the environment where Source Insight is
running. See “ProgEnvInfo Record” on page 380.
GetProgramInfo ()
Returns a ProgInfo structure, which contains information about Source Insight. See “ProgInfo Record” on page 381.
Other Information about Macros
Debugging
Source Insight does not contain a debugger for macros. However, since macros are interpreted, you can easily figure out what's going on by using the "Msg" function at strategic points in your code to output strings
and variable values. See “Msg (s)” on page 387.
To begin executing a macro statement at the current cursor position, use the Run Macro. Just put the insertion point on the line you want to start running at and invoke the Run Macro command.
You can dump the execution stack and variable state of a running macro by calling the DumpMacroState
function. See “DumpMacroState (hbufOutput)” on page 408.
Persistence
Global variables are preserved between runs, but not between sessions. Local variables are not preserved between runs or sessions. However, you can preserve values by storing them in a file, or writing and reading registry keys.
No Self-Modifying Macros
Make sure that a macro is not modifying itself while running. Source Insight will abort any macro that attempts to edit a file containing a running macro.
Sample Macros
A macro file is in included with Source Insight called "utils.em". This file contains some useful functions and you may want to look at it to see some examples.
408 Source Insight 4 User Guide