Hello,
You should change all of the "=" to ":=", as in
u := 1cm;
This instructs metapost to assign a value to the variable;
the standard form "u = 1cm" is a formula for metapost to solve.
It tries then to resolve u = 1cm; xmin = -2.6u; and xmax = 4u;
as a coupled set of equations. Sometimes you can get away with
this but in general one should use the := (assignment) form.
Consider, for example:
u = u + 1;
(a standard programming statement but nonsense for a mathematician).
Alan
On Sunday 05 December 2010 04:14:01 Li Yanrui (李延瑞) wrote:
> Hi,
>
> See the following example:
>
> \starttext
> \startMPcode
> u = 1cm;
> xmin = -2.6u;
> xmax = 4u;
> drawarrow (xmin,0)--(xmax,0);
> \stopMPcode
> \stoptext
>
> It can be compiled rightly. But when I add the 'label' line into it, see:
>
> \starttext
> \startMPcode
> u = 1cm;
> xmin = -2.6u;
> xmax = 4u;
> drawarrow (xmin,0)--(xmax,0);
> label.lft("hello",(0, 0));
> \stopMPcode
> \stoptext
>
> Now it can not be compiled and luatex outputs:
>
> mplib : loading 'metafun.mp' (experimental metapost version two)
> mplib > mp terminal: ! Redundant equation.
> <to be read again>
> ;
> <*> u = 1cm;
> xmin = -2.6u; xmax = 4u; drawarrow (xmin,0)--(xmax,0);
> label.lf...
>
> ! Redundant equation.
> <to be read again>
>
> Is this a bug or it always need to use 'save' macro to hold these
> local variable in metafun?
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : [email protected] / 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
___________________________________________________________________________________