mm44 -- Command

Macro processor
mm44 [ffiillee ...]

The command mm44 processes macros.  It allows you to define strings for which
mm44 is to search, and strings to replace them; mm44 then opens _f_i_l_e, reads its
contents, replaces  each macro with  its specified replacement  string, and
writes the results into the standard output stream.

mm44  can   also  manipulate   files,  make  conditional   decisions,  select
substrings, and  perform arithmetic.  The  tutorial _I_n_t_r_o_d_u_c_t_i_o_n _t_o  _t_h_e _m_4
_M_a_c_r_o _P_r_o_c_e_s_s_o_r introduces mm44 in detail.

mm44 reads its  _f_i_l_es in the order given; if  no _f_i_l_e is named, then it reads
the standard input stream.  The file name `-' indicates the standard input.

mm44 copies input  to output until it finds a  potential _m_a_c_r_o.  A macro is a
string of alphanumerics  (letters, digits, or underscores) that begins with
a non-digit  character and is surrounded by  non-alphanumerics.  If mm44 does
not recognize  the _m_a_c_r_o, it simply  copies it to the  output and continues
processing.  If  mm44 recognizes the _m_a_c_r_o  and the next character  is a left
parenthesis `(', an _a_r_g_u_m_e_n_t _s_e_t follows:

    macro(arg1,..., argn)

The arguments are collected by processing  them in the same manner as other
text (thus, an arguments may itself be another macro), and resulting output
text is  diverted into storage.  mm44  stores up to nine  arguments; any more
will be  processed but not saved.   An argument set consists  of strings of
text separated  by commas (commas inside quotation  marks or parentheses do
not terminate an argument),  and must contain balanced parentheses that are
free of  quotation marks (i.e., that are _u_n_q_u_o_t_e_d).  mm44 strips arguments of
unquoted leading space (blanks, tabs, newline characters).

mm44 then  removes the  _m_a_c_r_o and  its optional argument  set from  the input
stream,  processes them,  and replaces  them in the  input stream  with the
resulting value.  The value becomes the next piece of text to be read.

Quotation marks, of the form ` ',  inhibit  the  recognition of  _m_a_c_r_o.  mm44
strips off one level of  quotation marks when it encounters them (quotation
marks are  nestable).  Thus,  `_m_a_c_r_o' is not  processed, but is  changed to
_m_a_c_r_o and passed on.

mm44 determines  the _v_a_l_u_e of  a user-defined macro  by taking the  text that
constitutes the macro's _d_e_f_i_n_i_t_i_o_n and replacing any occurrence within that
text  of `$_n'  (where  _n is  `0'  through `9')  with  the text  of the  _nth
argument.  Argument 0 is the _m_a_c_r_o itself.

mm44 recognizes the following predefined macros:

cchhaannggeeqquuoottee[([_o_p_e_n_q_u_o_t_e],[_c_l_o_s_e_q_u_o_t_e])]
     Changes the quotation  characters.  Missing arguments default to ` for
     open or '  for close.  Quotation characters will not  nest if they are
     defined to be the same character.  Value is null.

ddeeccrr[(_n_u_m_b_e_r)]
     Decrement _n_u_m_b_e_r (default, 0) by one and returns resulting value.

ddeeffiinnee(_m_a_c_r_o,_d_e_f_i_n_i_t_i_o_n)
     Define  or redefine  _m_a_c_r_o. If  a predefined  macro is  redefined, its
     original definition is irrecoverably lost.  Value is null.

ddiivveerrtt[(_n)]
     Redirects output  to output stream _n (default  is zero).  The standard
     output  is zero,  and  one through  nine are  maintained as  temporary
     files.  Any other _n results in output being thrown away until the next
     ddiivveerrtt macro.  Value is null.

ddiivvnnuumm
     Value is current output stream number.

ddnnll  Delete to newline: removes all  characters from the input stream up to
     and including the next newline.  Value is null.

dduummppddeeff[(_m_a_c_r_o_s)]
     Value  is quoted  definitions of  all _m_a_c_r_os  specified, or  names and
     definitions of all defined macros if no arguments.

eerrrrpprriinntt(_t_e_x_t)
     Print _t_e_x_t on standard error file.  Value is null.

eevvaall(_e_x_p_r_e_s_s_i_o_n)
     Value  is a  number  that is  the  value of  evaluated _e_x_p_r_e_s_s_i_o_n.  It
     recognizes, in order  of decreasing precedence: parentheses, **, unary
     +  -, *  / %,  binary  + -,  relations, and  logicals.  Arithmetic  is
     performed in lloonnggs.

iiffddeeff(_m_a_c_r_o,_d_e_f_v_a_l_u_e,_u_n_d_e_f_v_a_l_u_e)
     Return _d_e_f_v_a_l_u_e if _m_a_c_r_o is defined, and _u_n_d_e_f_v_a_l_u_e if not.

iiffeellssee(_a_r_g_1,_a_r_g_2,_a_r_g_3...)
     Compares _a_r_g_1  and _a_r_g_2. If they  are the same, returns  _a_r_g_3. If not,
     and _a_r_g_4  is the  last argument,  return _a_r_g_4. Otherwise,  the process
     repeats, comparing  _a_r_g_4 and _a_r_g_5,  and so on.  Like  other mm44 macros,
     this takes a maximum of nine arguments.

iinncclluuddee(_f_i_l_e)
     Value is  the entire contents  of the _f_i_l_e  argument.  If _f_i_l_e  is not
     accessible, a fatal error results.

iinnccrr[(_n_u_m_b_e_r)]
     Increments given  _n_u_m_b_e_r (default, zero) by  one and returns resulting
     value.

iinnddeexx(_t_e_x_t,_p_a_t_t_e_r_n)
     Value is  a number  corresponding to position  of _p_a_t_t_e_r_n in  _t_e_x_t. If
     _p_a_t_t_e_r_n does not occur in _t_e_x_t, value is -1.

lleenn(_t_e_x_t)
     Value is a number that corresponds to length of _t_e_x_t.

mmaakkeetteemmpp(_f_i_l_e_n_a_m_e_X_X_X_X_X_X)
     Value is  _f_i_l_e_n_a_m_e with last six  characters, usually XXXXXXXXXXXX, replaced
     with current  process id  and a single  letter.  Same as  the COHERENT
     system call mmkktteemmpp().

ssiinncclluuddee(_f_i_l_e)
     Value  is the  entire contents  of  _f_i_l_e. If  _f_i_l_e is  not accessible,
     return null and continue processing.

ssuubbssttrr(_t_e_x_t[,_s_t_a_r_t[,_c_o_u_n_t]])
     Value is a substring of _t_e_x_t. _s_t_a_r_t may be left-oriented (nonnegative)
     or right-oriented (negative).   _c_o_u_n_t specifies how many characters to
     the right  (if positive) or to  the left (if negative)  to return.  If
     absent, it  is assumed to be  large and of the same  sign as _s_t_a_r_t. If
     _s_t_a_r_t is  omitted, it is  assumed to be  zero if _c_o_u_n_t  is positive or
     omitted, or -1 if _c_o_u_n_t is negative.

ssyyssccmmdd(_c_o_m_m_a_n_d)
     Pass  _c_o_m_m_a_n_d to  the shell  for execution.  Value  is null.   Same as
     system call ssyysstteemm.

ttrraannsslliitt(_t_e_x_t,_c_h_a_r_a_c_t_e_r_s[,_r_e_p_l_a_c_e_m_e_n_t_s])
     Replaces  _c_h_a_r_a_c_t_e_r_s in  _t_e_x_t with  the corresponding  characters from
     _r_e_p_l_a_c_e_m_e_n_t_s.  If the  _r_e_p_l_a_c_e_m_e_n_t_s is  absent  or too  short, replace
     _c_h_a_r_a_c_t_e_r_s  with  a  null character.   Value  is  _t_e_x_t with  specified
     replacements.

uunnddeeffiinnee(_m_a_c_r_o)
     Remove macro  definition.  Value  is null.   If a predefined  macro is
     redefined, its original definition is irrecoverably lost.

uunnddiivveerrtt[(_s_t_r_e_a_m[,...])]
     Dumps each  specified _s_t_r_e_a_m into the current  output stream.  With no
     arguments,  uunnddiivveerrtt dumps  all output streams  in numeric  order.  mm44
     will  not  dump  any  output  stream  into  itself.   At  the  end  of
     processing,  mm44  automatically dumps  all  diverted  text to  standard
     output in numeric order.  Value is null.

_S_e_e _A_l_s_o
ccoommmmaannddss, mmkktteemmpp(), ssyysstteemm
_I_n_t_r_o_d_u_c_t_i_o_n _t_o _t_h_e _m_4 _M_a_c_r_o _P_r_o_c_e_s_s_o_r
