A macro function is declared in a format that looks like a C function. White space is ignored, and function and variable names are not case sensitive. A macro function begins with either the macro or function keyword, followed by the name of the function. Here is a most basic function:
msg("Hello World!") // message box appears with "Hello World"
Macro functions can have parameters and can call other macros. You can return a value from a macro by using "return n" where n is the return value. For example:
return n + 2
There are three flavors of macro functions:
User-level commands you can assign to a key or menu. These must be declared with the macro keyword, and have no function parameters. The name of the command is the same as the macro function name.
Functions that are used as subroutines that you can call from other macro functions. These should be declared with the function keyword.
Event functions that are used to hook into events. These are declared with the event keyword. See: Macro Event Handlers.
For example, this function becomes a user-level command, and it can be assigned to a keystroke:
macro SaveCurrentFileNow ()
You can use Options > Key Assignments to locate the SaveCurrentFileNow command and assign a keystroke to it.
However this function can only be called from another macro function, because it is declared with the function keyword:
function perform_save ()
hbuf = GetCurrentBuf()
if (hbuf != nil)