Peter, Thanks for trying to help. Because I solved the problem in another way you might be interested or even benefit from it. The underlying problem was drawing a border around a picture of given dimensions. The border being either colored or left uncolored. The border color should come from a withcolor modifier, with the uncolored case done simply by leaving this out, for example: borderinsideframe(u,v,2g); and borderinsideframe(u,v,2g) withcolor red; It turns out this can be done with an unfill. I learned that a bare unfill erases, but add a withcolor modifier and the effect is a coloring. Thus the trick is: def bordercolorframe (expr w, h, off, clr) text modifier = unfill (-off,-off)--(w+off,-off)--(w+off,h+off)--(-off,h+off)--cycle modifier; fill (0,0)--(w,0)--(w,h)--(0,h)--cycle withcolor clr enddef; The omission of a semicolon after the last statement of the def allows one to add in a withcolor somecolor without triggering an error. Hope this will be of use to someone. Hans van der Meer On 21 okt. 2011, at 17:13, Peter Rolf wrote:
Am 21.10.2011 15:05, schrieb Hans van der Meer:
I cannot find the answer to the following question in Knuth's Metafont book. The following definition with a trailing text argument:
def mydef (expr a, b, c) text modifier = if
: Have you already tried
if modifier = "" :
else: fi enddef;
How can I do the switch on an empty or nonempty modifier argument? It is not a string because calling its length fails with an error. I must do the switch, because "fill modifier" with an empty "modifier" gives horrible results.
Usage would be calls like: mydef(1,2,3) withcolor green; % with modifier text mydef(1,2,3); % without modifier text
Thanks in advance. Hans van der Meer