ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Metapost example and code
@ 2001-04-29 10:53 Johannes Huesing
  2001-05-04 15:29 ` Hans Hagen
  0 siblings, 1 reply; 5+ messages in thread
From: Johannes Huesing @ 2001-04-29 10:53 UTC (permalink / raw)


Hi all,

I am trying to define a start-stop-environment which allows me to
prettyprint MetaPost code and display its results. This is what I
tried:

%%%% code begins here %%%%
\runMPgraphicstrue

\def\PreMPExample{\startbuffer[mpe]}

\def\PostMPExmaple{\stopbuffer%
   \startMPgraphic
     input mpe.tmp;
   \stopMPgraphic
   \placeMPgraphic[right]{none}
   \expandafter\startMP
     \input mpe.tmp
   \stopMP
   }    
\starttext
\stoptext

\startMPExample
 draw
 for i=0 upto 4:
   (50, 0) rotated (i*144) --
  endfor
 cycle;
\stopMPExample

\stoptext
%%%% code ends here %%%%

and this is what I got:

%%%% messages begin here %%%%
<mpe.tmp>
! Undefined control sequence.
<argument> \def \fontattribute 
                               {\getvalue {\??be MPExample\c!letter }}
\doifdefinedelse ...t \donottest \doprocesstest #2
                                                  \fi 
\do\dostartattributes ... \fontattribute =\empty }
                                                  \doifdefinedelse {#1#3} {\...
<write> ...es {\??be MPExample}\c!letter \c!kleur 
                                                  {}
<inserted text> 
                }\endwrite 
<argument> ...?be MPExample}\c!letter \c!kleur {}}

...
%%%% messages end here %%%%

Does anybody have an idea what I am doing wrong here? I didn't use the
useMPgraphics constructs in order not to have to worry clashing
temporary file names. 

Groetjes 

Johannes
-- 
Johannes Hüsing | Domain: Adresse im Internet. Besteht aus einem 
hannes@ruhrau.de| technischen Teil (http://www.), einem Namen 
                | (erwin_meier) und einer Endung  (zum Beispiel 
                | .de für Deutschland) [J. Albrecht, "Zeit" 12/2001]


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

* Re: Metapost example and code
  2001-04-29 10:53 Metapost example and code Johannes Huesing
@ 2001-05-04 15:29 ` Hans Hagen
  2001-05-06  4:15   ` Johannes Huesing
  0 siblings, 1 reply; 5+ messages in thread
From: Hans Hagen @ 2001-05-04 15:29 UTC (permalink / raw)
  Cc: ntg-context

At 12:53 PM 4/29/01 +0200, Johannes Huesing wrote:
>Hi all,
>
>I am trying to define a start-stop-environment which allows me to
>prettyprint MetaPost code and display its results. This is what I
>tried:
>
>
>%%%% code begins here %%%%
>\runMPgraphicstrue
>
>\def\PreMPExample{\startbuffer[mpe]}
>
>\def\PostMPExmaple{\stopbuffer%
>   \startMPgraphic
>     input mpe.tmp;
>   \stopMPgraphic
>   \placeMPgraphic[right]{none}
>   \expandafter\startMP
>     \input mpe.tmp
>   \stopMP
>   }    
>\starttext
>\stoptext
>
>\startMPExample
> draw
> for i=0 upto 4:
>   (50, 0) rotated (i*144) --
>  endfor
> cycle;
>\stopMPExample
>
>\stoptext
>%%%% code ends here %%%%
>
>and this is what I got:
>
>%%%% messages begin here %%%%
><mpe.tmp>
>! Undefined control sequence.

Buffers cannot be used in macros (although a workaround is to use
\definebuffer); but, why not use: 

\def\startMPExample#1\stopMPExample%
  {\startuseMPgraphic{MPExample}#1\stopuseMPgraphic
   \placefigure[right]{none}{\useMPgraphic{MPExample}}}

\startMPExample
 draw
 for i=0 upto 4:
   (50, 0) rotated (i*144) --
  endfor
 cycle;
\stopMPExample

Or simply: 

\startuseMPgraphic{MPExample}
 draw
 for i=0 upto 4:
   (50, 0) rotated (i*144) --
  endfor
 cycle;
\stopuseMPgraphic

\placefigure[right]{none}{\useMPgraphic{MPExample}}

Hans
-------------------------------------------------------------------------
                                  Hans Hagen | PRAGMA ADE | pragma@wxs.nl
                      Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
 tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------


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

* Re: Metapost example and code
  2001-05-04 15:29 ` Hans Hagen
@ 2001-05-06  4:15   ` Johannes Huesing
  2001-05-07  8:21     ` Hans Hagen
  0 siblings, 1 reply; 5+ messages in thread
From: Johannes Huesing @ 2001-05-06  4:15 UTC (permalink / raw)


On Fri, May 04, 2001 at 05:29:01PM +0200, Hans Hagen wrote:
> At 12:53 PM 4/29/01 +0200, Johannes Huesing wrote:

> >   \expandafter\startMP
                  ~~~~~~~~
> >     \input mpe.tmp
> >   \stopMP
      ~~~~~~~
> >   }    
[...]
> 
> Or simply: 
> 
> \startuseMPgraphic{MPExample}
>  draw
>  for i=0 upto 4:
>    (50, 0) rotated (i*144) --
>   endfor
>  cycle;
> \stopuseMPgraphic
> 
> \placefigure[right]{none}{\useMPgraphic{MPExample}}

Because I wanted to quote the example, prettyprinted, as well, 
and not have to edit the metaposted and the prettyprinted version 
in parallel.

Greetings

Johannes 
-- 
Johannes Hüsing | Domain: Adresse im Internet. Besteht aus einem 
hannes@ruhrau.de| technischen Teil (http://www.), einem Namen 
                | (erwin_meier) und einer Endung  (zum Beispiel 
                | .de für Deutschland) [J. Albrecht, "Zeit" 12/2001]


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

* Re: Metapost example and code
  2001-05-06  4:15   ` Johannes Huesing
@ 2001-05-07  8:21     ` Hans Hagen
  2001-05-08  6:19       ` Johannes Huesing
  0 siblings, 1 reply; 5+ messages in thread
From: Hans Hagen @ 2001-05-07  8:21 UTC (permalink / raw)
  Cc: ntg-context

At 06:15 AM 5/6/01 +0200, Johannes Huesing wrote:
>On Fri, May 04, 2001 at 05:29:01PM +0200, Hans Hagen wrote:
>> At 12:53 PM 4/29/01 +0200, Johannes Huesing wrote:
>
>> >   \expandafter\startMP
>                  ~~~~~~~~
>> >     \input mpe.tmp
>> >   \stopMP
>      ~~~~~~~
>> >   }    
>[...]
>> 
>> Or simply: 
>> 
>> \startuseMPgraphic{MPExample}
>>  draw
>>  for i=0 upto 4:
>>    (50, 0) rotated (i*144) --
>>   endfor
>>  cycle;
>> \stopuseMPgraphic
>> 
>> \placefigure[right]{none}{\useMPgraphic{MPExample}}
>
>Because I wanted to quote the example, prettyprinted, as well, 
>and not have to edit the metaposted and the prettyprinted version 
>in parallel.

Right, now you're thinking 'context': 

\startbuffer[whow]
  your := fance := mpcode ; 
\stopbuffer

\typebuffer[whow]

\placefigure{}{\processMPbuffer[whow]}

will be of help then

Hans
-------------------------------------------------------------------------
                                  Hans Hagen | PRAGMA ADE | pragma@wxs.nl
                      Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
 tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------


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

* Re: Metapost example and code
  2001-05-07  8:21     ` Hans Hagen
@ 2001-05-08  6:19       ` Johannes Huesing
  0 siblings, 0 replies; 5+ messages in thread
From: Johannes Huesing @ 2001-05-08  6:19 UTC (permalink / raw)


On Mon, May 07, 2001 at 10:21:41AM +0200, Hans Hagen wrote:
> At 06:15 AM 5/6/01 +0200, Johannes Huesing wrote:
[...]
> >
> >Because I wanted to quote the example, prettyprinted, as well, 
> >and not have to edit the metaposted and the prettyprinted version 
> >in parallel.
> 
> Right, now you're thinking 'context': 
> 
> \startbuffer[whow]
>   your := fance := mpcode ; 
> \stopbuffer
> 
> \typebuffer[whow]
> 
> \placefigure{}{\processMPbuffer[whow]}
> 

Ah, stupid me! Yes, I failed to look up \processMPbuffer in the 
Metafun manual.

> will be of help then
> 

And \definetyping[file][option=MP] does the job for prettyprinting
the \typebuffer'ed text.

Very nice. Thank you

Johannes
-- 
Johannes Hüsing | Domain: Adresse im Internet. Besteht aus einem 
hannes@ruhrau.de| technischen Teil (http://www.), einem Namen 
                | (erwin_meier) und einer Endung  (zum Beispiel 
                | .de für Deutschland) [J. Albrecht, "Zeit" 12/2001]


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

end of thread, other threads:[~2001-05-08  6:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-29 10:53 Metapost example and code Johannes Huesing
2001-05-04 15:29 ` Hans Hagen
2001-05-06  4:15   ` Johannes Huesing
2001-05-07  8:21     ` Hans Hagen
2001-05-08  6:19       ` Johannes Huesing

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