The macro DEFINEMACRO lets you define new macros. This macro requires three parameter lists:
  • An identifier, being the name of the macro to define. This identifier must only consist of uppercase or lowercase characters.
  • A number, stating the number of arguments that the macro will require once used. The number must be in the range 0 to 61.
  • The text that the macro will expand to, once used. This text may contain the strings ARGx, x being 1, 2, etc.. At these places the arguments to the macro will be pasted in. The numbers that identify the arguments are 1 to 9, then A to Z and finally a to z. This gives a range of 61 expandable arguments, that should be enough for most applications.
  • For example, the following fragment defines a macro bookref, which can be used to typeset a reference to a book. It requires three arguments; say, an author, a title and the name of a publisher:
    DEFINEMACRO(bookref)(3)
    (Author(s):           ARG1
    Book title:          ARG2
    Published by:        ARG3)
    

    Such a macro could be used as:

    bookref(Sobotta/Becher)
        (Atlas der Anatomie des Menschen)
        (Urban und Schwarzenberg, Berlin, 1972)
    

    It would of course lead to:

    Author(s):           Sobotta/Becher
    Book title:          Atlas der Anatomie des Menschen
    Published by:        Urban und Schwarzenberg, Berlin, 1972
    

    While applying a macro, the three parameter lists are pasted to the places where ARG1, ARG2 etc. occur in the definition.

    A few caveats when defining new macros are:

  • The parameter list containing the name of the new macro, (bookref) in the above example, must occur right after DEFINEMACRO. No spaces are allowed in between. Space characters and newlines may however occur following this first parameter list.

    This behavior of the yodl program is similar to the usage of the defined macro: the author information must, enclosed in parentheses, follow right after the bookref identifier. I implemented this feature to improve the distinguishing between macros and real text. E.g., a macro me might be defined, but the text

    I like me (but so do you)
    

    still is simple text; the macro me only is activated when a parenthesis immediately follows it.

  • Be careful when placing newlines or spaces in the definition of a new macro. E.g., the definition

    DEFINEMACRO(bookref)(3)(
    Author(s):           ARG1
    Book title:          ARG2
    Published by:        ARG3)
    

    introduces an extra newline, that will be copied to the output each time that the macro is used. The extra newline occurs, of course, right before the sequence Author(s):. A simple backslash character at the end of the DEFINEMACRO line would prevent the insertion of an extra newline character.

  • Note that when a macro is used which requires no arguments at all, one empty parameter list still must be specified. E.g., my macro package (see chapter ??) defines a macro it that starts a bullet item in a list. The macro takes no arguments, but still must be typed as it().

    This behavior is consistent: it helps distinguish which identifiers are macros and which are simple text.


  • Go back to index of Yodl.

    Please send Yodl questions and comments to yodl@icce.rug.nl.

    Please send comments on these web pages to (address unknown)

    Copyright (c) 1997, 1998, 1999 Karel Kubat and Jan Nieuwenhuizen.

    Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.


    This page was built from Yodl-1.31.18 by

    <(address unknown)>, Wed Mar 5 04:23:51 2008 EST.