[metapost] Error when defining a function
Hartmut Henkel
hartmut_henkel at gmx.de
Fri Jun 15 08:47:42 CEST 2007
On Thu, 14 Jun 2007, Peng Yu wrote:
> I couldn't figure out what is wrong with the following metapost
> program. Would you please help me?
> $ cat psm.mp
> u := 1cm;
> beginfig(1);
>
> numeric glass[];
> glass[0] := -2*u;
> glass[1] := 2*u;
>
> def drawrect(expr x1, x2, y1, y2) =
> draw (x1,y1)--(x2,y1)--(x2,y2)--(x1,y2)--cycle
> enddef;
>
> drawrect(glass[0], glass[1], 0, 1cm);
> endfig;
> end;
you can't write e. g. x1 as parameter, as these are two tokens: the 'x'
and the '1'. But an expr parameter must be something that's a "symbolic
token", see MetaPost book page 51. You can write (expr xa, xb, ya, yb),
as "xa" is a symbolic token.
Regards, Hartmut
More information about the metapost
mailing list