The macro IFEMPTY
expects three arguments: a symbol, a true-list and a
false-list. The macro evaluates to the true-list if the symbol is an empty
string; otherwise, it evaluates to the false-list.
A trivial example is the following:
IFEMPTY(something) \ ("something" is supposedly nothing ?!?") ("something" is not an empty string)
In the same way, IFEMPTY
can be used to test whether a macro expands to a
non-empty string. A more elaborate example follows below. Say you want to
define a bookref
macro to typeset information about an author, a book
title and about the publisher. The publisher information may be absent, the
macro then typesets unknown
:
DEFINEMACRO(bookref)(3)(\ Author(s): ARG1 Title: ARG2 Published by: IFEMPTY(ARG3)(Unknown)(ARG3))
Using the macro, as in:
bookref(Helmut Leonhardt) (Histologie, Zytologie und Microanatomie des Menschen) ()
would of course supply Unknown
in the Published by:
line.
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.