Here is the basic structure of a NeXtMidas macro:
! This macro takes a name argument that defaults to "SUPERMAN" if ! not provided and displays a greeting message to the named person startmacro s:name[Superman] ! This is another comment say "Hello there ^{name}!" ... endmacro procedure processMessage m:msg say "msg.name ^msg.name, data ^msg.data" ... return procedure processException m:emsg ... return
The first line defines the parameters supplied at run-time. Defaults can be given
for unconfigured macros by putting the default values in square brackets immediately
after the parameter name (no spaces), configured macros specify their defaults in the
command dictionary (see UPDATE
), an entry in the command dictionary
overrides any default given at the top of the macro.
By default, all results created by a macro have local scope only.
They are not accessible by other macros and are automatically destroyed
at macro completion. Global results are always available for read access.
To make global results writable by a macro, it must be called out using
the GLOBAL
statement.
The processMessage
is automatically sent any messages
passed to the macro. Optionally processException
can be used to override
the default exception handling (this is extremely rare).
Configured macros are invoked just like any other command (name followed by
the macro arguments). If the macro is a user macro, you must always begin the name
with the percent sign (%
). Execution then proceeds through each
statement between STARTMACRO
and ENDMACRO
. To see the
constituent macro statements as they execute, type VERIFY ON
before
running the macro. When the macro completes, it returns to the NeXtMidas prompt.