ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Why does this METAPOST vardef 'save' statement fail?
@ 2020-03-14 14:45 Gerben Wierda
  2020-03-14 14:50 ` Gerben Wierda
  0 siblings, 1 reply; 2+ messages in thread
From: Gerben Wierda @ 2020-03-14 14:45 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1041 bytes --]

I have this vardef:

vardef Foo(expr w, h) =
   save pth; path pth;
   %save pth2; path pth2;
   save pic; picture pic;
   pth = fullsquare xysized (w, h);
   %pth2 = fullsquare xysized (h/4, h/8)
   pic := image (
       draw pth;
       %draw pth2 shifted (-w/2, -h/4);
       % all kind of stuff here
   );
   setbounds pic to pth;
   pic
enddef ;

As soon as I uncomment the bold line (first comment) a mtxrun fails. Whatever I try, a single save statement, etc., I fail in getting a second local variable. The METAPOST manual is no help.

The error shown is:

metapost log    > ! Extra tokens will be flushed.
metapost log    > <to be read again> 
metapost log    >                    2
metapost log    > Foo->...h;path.pth;save.pth2
metapost log    >                                                   ;path.pth2;save.pic;pictur...
metapost log    > <*> ... ; s := Foo(8cm, 2cm)
metapost log    >                                                   ; draw s; drawdot center l...
metapost log    > 

Why?

G

[-- Attachment #1.2: Type: text/html, Size: 5276 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Why does this METAPOST vardef 'save' statement fail?
  2020-03-14 14:45 Why does this METAPOST vardef 'save' statement fail? Gerben Wierda
@ 2020-03-14 14:50 ` Gerben Wierda
  0 siblings, 0 replies; 2+ messages in thread
From: Gerben Wierda @ 2020-03-14 14:50 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1785 bytes --]

Answering myself: pth2 is not a valid variable name. Digits are not allowed.

> On 14 Mar 2020, at 15:45, Gerben Wierda <gerben.wierda@rna.nl> wrote:
> 
> I have this vardef:
> 
> vardef Foo(expr w, h) =
>    save pth; path pth;
>    %save pth2; path pth2;
>    save pic; picture pic;
>    pth = fullsquare xysized (w, h);
>    %pth2 = fullsquare xysized (h/4, h/8)
>    pic := image (
>        draw pth;
>        %draw pth2 shifted (-w/2, -h/4);
>        % all kind of stuff here
>    );
>    setbounds pic to pth;
>    pic
> enddef ;
> 
> As soon as I uncomment the bold line (first comment) a mtxrun fails. Whatever I try, a single save statement, etc., I fail in getting a second local variable. The METAPOST manual is no help.
> 
> The error shown is:
> 
> metapost log    > ! Extra tokens will be flushed.
> metapost log    > <to be read again> 
> metapost log    >                    2
> metapost log    > Foo->...h;path.pth;save.pth2
> metapost log    >                                                   ;path.pth2;save.pic;pictur...
> metapost log    > <*> ... ; s := Foo(8cm, 2cm)
> metapost log    >                                                   ; draw s; drawdot center l...
> metapost log    > 
> 
> Why?
> 
> G
> ___________________________________________________________________________________
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________


[-- Attachment #1.2: Type: text/html, Size: 6795 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-14 14:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-14 14:45 Why does this METAPOST vardef 'save' statement fail? Gerben Wierda
2020-03-14 14:50 ` Gerben Wierda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).