Re: [NTG-context] metafun: error when I call the same function twice consecutively.

2018-06-01 Thread Jeong Dal
Dear Alan,

Thank you for the clear explanation about z.
I tought that z is a special variable different from other pairs.
Now, I know that it is an equation.

Thank you again.

Best regards,

Dalyoung

> 2018. 6. 1. 오후 11:24, Alan Braslau  작성:
> 
> On Fri, 01 Jun 2018 20:29:41 +0900
> Jeong Dal  wrote:
> 
>> After inserting a line “save x, y;”, it works.
> 
> This is also defined as "clearxy ;"
> 
> For those learning MetaPost, simplifying, z is defined as "(x,y)" so
> one can write
>   z = (a,b) ;
> This is an EQUATION in MetaPost
>   (x,y) = (a,b) ;
> not an assignment (as in most other languages), actually a pair of
> equations:
>   x = a ; y = b ;
> When x and y are unknown, this can be "solved". When x and y contain
> values, it leads to "inconsistent equations".
> 
> One *cannot* write
>   z =: (a,b) ;
> ("=:" is the assignment operator),
> for z is just a macro, not a "pair" object or variable.
> 
> This can be *very* confusing when learning MetaPost.
> 
> Alan
> 
> P.S.
>   for i=0 upto n:
>   z[i] = (i,0) ;
>   endfor
> works as each element of the (pseudo)array z is unknown, at least the
> first time that it is used.

___
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
___

Re: [NTG-context] metafun: error when I call the same function twice consecutively.

2018-06-01 Thread Alan Braslau
On Fri, 01 Jun 2018 20:29:41 +0900
Jeong Dal  wrote:

> After inserting a line “save x, y;”, it works.

This is also defined as "clearxy ;"

For those learning MetaPost, simplifying, z is defined as "(x,y)" so
one can write
z = (a,b) ;
This is an EQUATION in MetaPost
(x,y) = (a,b) ;
not an assignment (as in most other languages), actually a pair of
equations:
x = a ; y = b ;
When x and y are unknown, this can be "solved". When x and y contain
values, it leads to "inconsistent equations".

One *cannot* write
z =: (a,b) ;
("=:" is the assignment operator),
for z is just a macro, not a "pair" object or variable.

This can be *very* confusing when learning MetaPost.

Alan

P.S.
for i=0 upto n:
z[i] = (i,0) ;
endfor
works as each element of the (pseudo)array z is unknown, at least the
first time that it is used.
___
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
___

Re: [NTG-context] metafun: error when I call the same function twice consecutively.

2018-06-01 Thread Jeong Dal
Dear Henri Menke,

Thank you for the solution.
After inserting a line “save x, y;”, it works.

Thank you so much.

Best regards,

Dalyoung

___
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
___

Re: [NTG-context] metafun: error when I call the same function twice consecutively.

2018-05-31 Thread Henri Menke



On 01/06/18 14:22, Jeong Dal wrote:

Hi,

I defined a function using MetaFun, and call it to draw a figure.
It is OK when I call it once.
But there is an error when it runs the same function second time.
(it stops when it call fap(3,2) after fap(2,2))

I have no idea what is wrong and how to fix it.
Would you please tell me what I miss?


You have to save x, y; otherwise z[i] = ... will be an ill-defined equation.

\startMPpage
numeric u;  u := 1cm;
path p[];

def fap(expr n, m) =
begingroup ; save x, y ;
numeric size ; size := m*u ;

for i = 0 upto (n*n-1):
z[i] = ((i mod n),(floor(i/n)))*size;
drawdot z[i] withpen pencircle scaled 5pt withcolor blue;
endfor ;
endgroup ;
enddef;

fap(2,2);
fap(3,2);
\stopMPpage



Thank you.
Best regards,

Dalyoung

%%%
\startbuffer[test]
numeric u;  u := 1cm;
path p[];

def fap(expr n, m) =
numeric size; size := m*u;

for i = 0 upto (n*n-1):
z[i] = ((i mod n),(floor(i/n)))*size;
drawdot z[i] withpen pencircle scaled 5pt withcolor blue;
endfor;
enddef;

fap(2,2);
fap(3,2);
\stopbuffer
  
\starttext

\processMPbuffer[test]
\stoptext

___
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
___


___
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
___

[NTG-context] metafun: error when I call the same function twice consecutively.

2018-05-31 Thread Jeong Dal
Hi,

I defined a function using MetaFun, and call it to draw a figure.
It is OK when I call it once.
But there is an error when it runs the same function second time.
(it stops when it call fap(3,2) after fap(2,2))

I have no idea what is wrong and how to fix it.
Would you please tell me what I miss?

Thank you.
Best regards,

Dalyoung

%%%
\startbuffer[test]
numeric u;  u := 1cm;
path p[];

def fap(expr n, m) = 
numeric size; size := m*u;

for i = 0 upto (n*n-1):
z[i] = ((i mod n),(floor(i/n)))*size;
drawdot z[i] withpen pencircle scaled 5pt withcolor blue;
endfor;
enddef;

fap(2,2);
fap(3,2);
\stopbuffer
 
\starttext
\processMPbuffer[test]
\stoptext

___
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
___

Re: [NTG-context] Metafun error

2014-09-27 Thread Willi Egger
Hi Otared, 
thank you for this! - I do not understand correctly what has happened here. Now 
after rebooting it works again….. ;-(

Thanks!

Willi
On 26 sep. 2014, at 23:09, Otared Kavian ota...@gmail.com wrote:

 Hi Willi,
 
 I just updated to
   ConTeXt  ver: 2014.09.26 11:42 MKIV beta  fmt: 2014.9.26  int: 
 english/english
 and tested again your example: everything works as expected here…
 
 So probably there is something strange happening on your side.
 
 Best regards: OK
 
 On 26 Sep 2014, at 16:22, Willi Egger cont...@boede.nl wrote:
 
 Hi Otared,
 
 As mentioned in my first post I tested on  
  ConTeXt  ver: 2014.08.29 20:57
   ConTeXt  ver: 2014.09.26 11:42.
 
 strange!
 
 Willi
 On 26 sep. 2014, at 15:23, Otared Kavian ota...@gmail.com wrote:
 
 Hi Willi,
 
 I tested your example file: it works fine here with
 ConTeXt  ver: 2014.09.25 18:58 MKIV beta  fmt: 2014.9.25  int: 
 english/english
 Which version are using?
 
 Best regards: OK
 
 On 26 Sep 2014, at 15:17, Willi Egger cont...@boede.nl wrote:
 
 Hello!
 
 Today I wanted to use an older tex file…. I get the same error as in the 
 following test.
 
 \startuniqueMPgraphic{test}
 
path p;
p := fullcircle scaled 5cm;
draw p;
label.bot(textext(Centre), center p);

 \stopuniqueMPgraphic
 
 \starttext
 \startTEXpage
 \useMPgraphic{test} 
 \stopTEXpage
 \stoptext
 
 ___
 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
 ___
 
 ___
 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
 ___
 
 ___
 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
 ___

___
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
___


[NTG-context] Metafun error

2014-09-26 Thread Willi Egger
Hello!

Today I wanted to use an older tex file…. I get the same error as in the 
following test.

\startuniqueMPgraphic{test}

path p;
p := fullcircle scaled 5cm;
draw p;
label.bot(textext(Centre), center p);

\stopuniqueMPgraphic

\starttext
\startTEXpage
\useMPgraphic{test} 
\stopTEXpage
\stoptext


The error message is:

Argument of \meta_start_environment has an extra }

inserted text 
\par 
to be read again 
}
\meta_handle_unique_graphic ...ocess_graphic {#3}}
  \setxvalue {\??mpgraphic \...
\meta_use_graphic ...]}\getvalue {\??mpgraphic #1}
  \empty \meta_end_graphic_g...
to be read again 
 
l.288 \useMPgraphic{test}

This error occurs as well with version ConTeXt  ver: 2014.08.29 20:57 as with 
the latest beta ConTeXt  ver: 2014.09.26 11:42.


Am I missing something?

Kind regards

Willi
___
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
___


Re: [NTG-context] Metafun error

2014-09-26 Thread Otared Kavian
Hi Willi,

I tested your example file: it works fine here with
ConTeXt  ver: 2014.09.25 18:58 MKIV beta  fmt: 2014.9.25  int: 
english/english
Which version are using?

Best regards: OK

On 26 Sep 2014, at 15:17, Willi Egger cont...@boede.nl wrote:

 Hello!
 
 Today I wanted to use an older tex file…. I get the same error as in the 
 following test.
 
 \startuniqueMPgraphic{test}
 
   path p;
   p := fullcircle scaled 5cm;
   draw p;
   label.bot(textext(Centre), center p);
   
 \stopuniqueMPgraphic
 
 \starttext
 \startTEXpage
\useMPgraphic{test} 
 \stopTEXpage
 \stoptext

___
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
___


Re: [NTG-context] Metafun error

2014-09-26 Thread Willi Egger
Hi Otared,

As mentioned in my first post I tested on  
ConTeXt  ver: 2014.08.29 20:57
ConTeXt  ver: 2014.09.26 11:42.

strange!

Willi
On 26 sep. 2014, at 15:23, Otared Kavian ota...@gmail.com wrote:

 Hi Willi,
 
 I tested your example file: it works fine here with
   ConTeXt  ver: 2014.09.25 18:58 MKIV beta  fmt: 2014.9.25  int: 
 english/english
 Which version are using?
 
 Best regards: OK
 
 On 26 Sep 2014, at 15:17, Willi Egger cont...@boede.nl wrote:
 
 Hello!
 
 Today I wanted to use an older tex file…. I get the same error as in the 
 following test.
 
 \startuniqueMPgraphic{test}
 
  path p;
  p := fullcircle scaled 5cm;
  draw p;
  label.bot(textext(Centre), center p);
  
 \stopuniqueMPgraphic
 
 \starttext
 \startTEXpage
   \useMPgraphic{test} 
 \stopTEXpage
 \stoptext
 
 ___
 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
 ___

___
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
___


Re: [NTG-context] Metafun error

2014-09-26 Thread Otared Kavian
Hi Willi,

I just updated to
ConTeXt  ver: 2014.09.26 11:42 MKIV beta  fmt: 2014.9.26  int: 
english/english
and tested again your example: everything works as expected here…

So probably there is something strange happening on your side.

Best regards: OK

On 26 Sep 2014, at 16:22, Willi Egger cont...@boede.nl wrote:

 Hi Otared,
 
 As mentioned in my first post I tested on  
   ConTeXt  ver: 2014.08.29 20:57
ConTeXt  ver: 2014.09.26 11:42.
 
 strange!
 
 Willi
 On 26 sep. 2014, at 15:23, Otared Kavian ota...@gmail.com wrote:
 
 Hi Willi,
 
 I tested your example file: it works fine here with
  ConTeXt  ver: 2014.09.25 18:58 MKIV beta  fmt: 2014.9.25  int: 
 english/english
 Which version are using?
 
 Best regards: OK
 
 On 26 Sep 2014, at 15:17, Willi Egger cont...@boede.nl wrote:
 
 Hello!
 
 Today I wanted to use an older tex file…. I get the same error as in the 
 following test.
 
 \startuniqueMPgraphic{test}
 
 path p;
 p := fullcircle scaled 5cm;
 draw p;
 label.bot(textext(Centre), center p);
 
 \stopuniqueMPgraphic
 
 \starttext
 \startTEXpage
  \useMPgraphic{test} 
 \stopTEXpage
 \stoptext
 
 ___
 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
 ___
 
 ___
 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
 ___

___
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
___