ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Re: MetaPost with Multiple Variable Sections
       [not found] <mailman.1.1568800801.9194.ntg-context@ntg.nl>
@ 2019-09-18 23:35 ` Jeong Dal
  0 siblings, 0 replies; 3+ messages in thread
From: Jeong Dal @ 2019-09-18 23:35 UTC (permalink / raw)
  To: list ntg-context@ntg.nl ntg-context@ntg.nl ntg-context@ntg.nl
	ntg-context@ntg.nl

Dear Jeroen,

If you change “pair a;” to “numeric a;” in the second MPcode, it draws a circle without error.

Best regards,

Dalyoung

> 
> \placefloatright{}{
> \startMPcode
> pair a;

numeric a;

> a := 2cm;
> draw fullcircle scaled (2*a);
> \stopMPcode}
> 
> \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
___________________________________________________________________________________

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

* Re: MetaPost with Multiple Variable Sections
  2019-09-18  7:35 Jeroen
@ 2019-09-18 12:26 ` Aditya Mahajan
  0 siblings, 0 replies; 3+ messages in thread
From: Aditya Mahajan @ 2019-09-18 12:26 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Wed, 18 Sep 2019, Jeroen wrote:

> \startMPcode
> pair a;
> a := 2cm;

You define a to be a pair and then assign it to a number. Metapost is 
telling you that you cannot do that:

>> (xpart a,ypart a)
>> 56.6929
! Equation cannot be performed (pair=numeric).
<to be read again>
;
<*> pair a; a := 2cm;
draw fullcircle scaled (2*a); ;
I'm sorry, but I don't know how to make such things equal.
(See the two expressions just above the error message.)

You can fix that by saying

numeric a;
a := 2cm;

One needs to keep in mind that all the code in multiple MPcode 
environments are run in the same scope. I occasonally use

\startMPcode
begingroup;
...
endgroup;
\stopMPcode

to avoid interference.

Aditya
___________________________________________________________________________________
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] 3+ messages in thread

* MetaPost with Multiple Variable Sections
@ 2019-09-18  7:35 Jeroen
  2019-09-18 12:26 ` Aditya Mahajan
  0 siblings, 1 reply; 3+ messages in thread
From: Jeroen @ 2019-09-18  7:35 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

I have been working with MetaPost as following, which worked fine with one
startMPcode section with variables, but with 2 startMPcode Metapost
sections, it keeps telling me the numbers dont add up:


\definefloat      [floatright][figure]
\setupfloat       [floatright][default={right,none}]
\setuplayout      [backspace=20mm,width=170mm,topspace=20mm,height=250mm]

\starttext

\placefloatright{}{
\startMPcode
pair a, b;
a := (0,0);
b := (50,50);
draw a -- b;
\stopMPcode}

\placefloatright{}{
\startMPcode
pair a;
a := 2cm;
draw fullcircle scaled (2*a);
\stopMPcode}

\stoptext


I also have tried with the startbuffer combination as below, but this gave
the same error codes. Is there any other way of working with multiple
MetaPost sections with variables in a single document?


\definefloat      [floatright][figure]
\setupfloat       [floatright][default={right,none}]
\setuplayout      [backspace=20mm,width=170mm,topspace=20mm,height=250mm]

\starttext

\startbuffer
\startMPcode
pair a, b;
a := (0,0);
b := (50,50);
draw a -- b;
\stopMPcode
\stopbuffer

\floatright{}{\getbuffer}

\startbuffer
\startMPcode
pair a;
a := 2cm;
draw fullcircle scaled (2*a);
\stopMPcode
\stopbuffer

\floatright{}{\getbuffer}

\stoptext

[-- Attachment #1.2: Type: text/html, Size: 1468 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] 3+ messages in thread

end of thread, other threads:[~2019-09-18 23:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <mailman.1.1568800801.9194.ntg-context@ntg.nl>
2019-09-18 23:35 ` MetaPost with Multiple Variable Sections Jeong Dal
2019-09-18  7:35 Jeroen
2019-09-18 12:26 ` Aditya Mahajan

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).