prev | toc | next

3.2.3 MUF Macros

As with MPI, you can define macros — snippets of reusable code called by a single statement — with MUF. In fact, viewing defined macros and defining new ones is easier with MUF than with MPI.

To view, define, or delete MUF macros, you need to be in the MUF editor. You can use any program when invoking the editor; the defined macros are available to all programs.

Viewing Macros: In the editor, type either s (to see the long version of macro definitions) or a (to see the abridged version).

(The example output below is slightly reformatted.)

> @edit tinker.muf
> s

  abs          Jessy ( i -- i' ) dup 0 < if -1 * then

  after_match  Jessy (d -- ) dup #-1 dbcmp swap #-2 dbcmp or if exit then

  atodbref     Jessy ( s -- d ) "" "#" subst atoi dbref

  . ( .... entries omitted .... )

  wizard?      Jessy ( -- i ) "W" flag?

  yes?         Jessy ( s -- i ) ( checks that string starts with y ) 1
  strcut pop "y" stringcmp not

  End of list.

> a

abs             addpropstr     after_match    atodbref       confirm
debug-line debug-off debug-on me_wiz? no?
notify_nospam otell pmatch puppet? quote
rstrfmt spc80 split tell wizard?

  End of list.

Defining Macros: In the editor (but not while you are inserting code), type def <macro name> <macro definition>.

> @edit tinker.muf
> def nukestack ( x..x' -- ) begin depth while pop repeat
  Entry created.

Deleting Macros: Only wizards can delete macros, so, if you are a non-wizard Mucker entering macros, be sure you have it right when you enter it. If you are a wizard and want to delete a macro, type <macro name> kill while in the editor.

> @edit tinker.muf
> nukestack kill
  Macro entry deleted.

prev | toc | top | next