NXM Help MACRO
Jump to navigation
Jump to search
Summary: Covers the NeXtMidas macro language syntax.
Macros are scripts written in the Midas language. They are usually interpreted languages that may or may not have a translation step. In X-Midas, macros have a text (.txt) and binary (.mcr) form. In NeXtMidas, only the text (.mm) form is used.
Translation - the just-in-time translator
NeXtMidas macros employ a just-in-time translator. Labels, procedures, and subroutines, are resolved at load time. Each command line is parsed into an args table and the command object is loaded the first time the command is run. Subsequent passes through the code have minimal overhead. Control flow is implemented in the corresponding Intrinsic command using jumps evaluated during translation.
Unlike X-Midas there are no .TXT or .MCR files. A NeXtMidas macro has the extension .MM for Midas Macro. Since it is translated on-the-fly, there are no translated files (.MCR) on disk. The extension is changed to allow backward support of X-Midas macros.
Setup - Graphical setup files
The graphical (.SET) files of X-Midas are replaced with (.MMP) for Midas Macro Properties. This file holds graphical as well as non-graphical tuning parameters that are undesirable in the macro text for clarity and re-use reasons. For example, a macro that can be run locally, remotely, or in a browser may have significantly different graphical setups. This can be handled in separate .MMP files instead of multiple if-then-else statements within the macro.
Structure - the basic structure of a NeXtMidas macro
The basic structure is shown below:
startmacro a:arg1[default1] n:arg2[123] local res1 res2 res3 global appstate command1 in=arg1 out=_cb1 command2 in=_cb1 out=_cb2 endmacro
procedure open return
procedure process return
procedure processMessage m:msg return
procedure processException m:emsg return
procedure close return
procedure proc1 s:file=default d:mode return
procedure proc2 return
subroutine sub1 s:file=default d:mode return
The first line defines the results names that will contain the parameters supplied at run-time or by the defaults in the command configuration.
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 a global results writable by a macro, it must be called out using the GLOBAL statement. The LOCAL command is optional, but can be used with the GLOBAL and IMPLICIT statements to enforce strong type checking.
The open, process, processMessage, and close procedures apply only to piped macros.
Control flow and argument parsing overhead for a 3 arg command in a NeXtMidas macro measures approximately 35uSec on a 266MHz laptop.