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 <modifier = empty>: > > Have you already tried > > if modifier = "" : > > >> else: >> fi >> enddef;
I tried it now, but it doesn't work. Something like if(TEXT4) ="":;fi in the error log. No, Metapost is not happy with this construct. >> >> 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 ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________