ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* TeX trigger in MP macro
@ 2006-08-03 12:29 Peter Rolf
  2006-08-03 23:01 ` Hans Hagen
  0 siblings, 1 reply; 12+ messages in thread
From: Peter Rolf @ 2006-08-03 12:29 UTC (permalink / raw)


Hi all,

Currently I am using

\startuniqueMPgraphic{foo}
  ...
  if (\DbgFill=0) :
    fill whatever
  fi
  ...
\stopuniqueMPgraphic

in my MP graphics. \DbgFill (0|1) is just a trigger, which prevents
filling in case of visual debugging. Instead of always writing this
'long' form, it should be possible to use a self written mp-macro
instead. But my naive approach

def dbg_fill (expr p) =
  if (\DbgFill=0) :
    fill p ;
  fi
enddef ;

doesn't work. I get

>> DbgFill
! Unknown relation will be considered false.


How do I realize this trigger inside pure MP code and set it outside in
TeX? The trigger should be global and can change during runtime. Any
help is welcome.

Greetings, Peter

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

* Re: TeX trigger in MP macro
  2006-08-03 12:29 TeX trigger in MP macro Peter Rolf
@ 2006-08-03 23:01 ` Hans Hagen
  2006-08-04 10:57   ` Peter Rolf
  0 siblings, 1 reply; 12+ messages in thread
From: Hans Hagen @ 2006-08-03 23:01 UTC (permalink / raw)


Peter Rolf wrote:
> Hi all,
>
> Currently I am using
>
> \startuniqueMPgraphic{foo}
>   ...
>   if (\DbgFill=0) :
>     fill whatever
>   fi
>   ...
> \stopuniqueMPgraphic
>
> in my MP graphics. \DbgFill (0|1) is just a trigger, which prevents
> filling in case of visual debugging. Instead of always writing this
> 'long' form, it should be possible to use a self written mp-macro
> instead. But my naive approach
>
> def dbg_fill (expr p) =
>   if (\DbgFill=0) :
>     fill p ;
>   fi
> enddef ;
>
> doesn't work. I get
>
>   
>>> DbgFill
>>>       
> ! Unknown relation will be considered false.
>
>
> How do I realize this trigger inside pure MP code and set it outside in
> TeX? The trigger should be global and can change during runtime. Any
> help is welcome.
>   
can you make a test file? 

Hans 

-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------

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

* Re: TeX trigger in MP macro
  2006-08-03 23:01 ` Hans Hagen
@ 2006-08-04 10:57   ` Peter Rolf
  2006-08-04 11:14     ` Taco Hoekwater
  0 siblings, 1 reply; 12+ messages in thread
From: Peter Rolf @ 2006-08-04 10:57 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1957 bytes --]

Hans Hagen wrote:
> Peter Rolf wrote:
>> Hi all,
>>
>> Currently I am using
>>
>> \startuniqueMPgraphic{foo}
>>   ...
>>   if (\DbgFill=0) :
>>     fill whatever
>>   fi
>>   ...
>> \stopuniqueMPgraphic
>>
>> in my MP graphics. \DbgFill (0|1) is just a trigger, which prevents
>> filling in case of visual debugging. Instead of always writing this
>> 'long' form, it should be possible to use a self written mp-macro
>> instead. But my naive approach
>>
>> def dbg_fill (expr p) =
>>   if (\DbgFill=0) :
>>     fill p ;
>>   fi
>> enddef ;
>>
>> doesn't work. I get
>>
>>   
>>>> DbgFill
>>>>       
>> ! Unknown relation will be considered false.
>>
>>
>> How do I realize this trigger inside pure MP code and set it outside in
>> TeX? The trigger should be global and can change during runtime. Any
>> help is welcome.
>>   
> can you make a test file? 
>
I tried and my example code works at the beginning. After some changes
things run wild (only possible in TeX ;) ). Not even the 'long' form
worked any more.

So I went to contextlive and copied the simple test file. To my
astonishment it didn't work either. But more important, the log file
shows the same MetaPost error message I get, since ConTeXt swapped to
ruby (preventing me from updating). Testfile and context live log (html)
are attached.
If someone can solve this problem I would be very glad.

Greetings, Peter


> Hans 
> 
> -----------------------------------------------------------------
>                                           Hans Hagen | PRAGMA ADE
>               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>      tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
>                                              | www.pragma-pod.nl
> -----------------------------------------------------------------
> 
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context
> 
> 


[-- Attachment #2: test.zip --]
[-- Type: application/x-zip-compressed, Size: 3085 bytes --]

[-- Attachment #3: Type: text/plain, Size: 139 bytes --]

_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context

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

* Re: TeX trigger in MP macro
  2006-08-04 10:57   ` Peter Rolf
@ 2006-08-04 11:14     ` Taco Hoekwater
  2006-08-04 11:17       ` Taco Hoekwater
  0 siblings, 1 reply; 12+ messages in thread
From: Taco Hoekwater @ 2006-08-04 11:14 UTC (permalink / raw)



Hi Peter,

Peter Rolf wrote:
> If someone can solve this problem I would be very glad.

Adding a semicolon after the 'endgroup' command removes
the error.

Cheers, Taco

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

* Re: TeX trigger in MP macro
  2006-08-04 11:14     ` Taco Hoekwater
@ 2006-08-04 11:17       ` Taco Hoekwater
  2006-08-04 12:27         ` Peter Rolf
  2006-08-04 14:26         ` Peter Rolf
  0 siblings, 2 replies; 12+ messages in thread
From: Taco Hoekwater @ 2006-08-04 11:17 UTC (permalink / raw)


Taco Hoekwater wrote:
> Hi Peter,
> 
> Peter Rolf wrote:
> 
>>If someone can solve this problem I would be very glad.
> 
> 
> Adding a semicolon after the 'endgroup' command removes
> the error.

(I just looked at your pdf document).

You probably want 'useMPgraphic' instead of 'uniqueMPgraphic'.

Taco

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

* Re: TeX trigger in MP macro
  2006-08-04 11:17       ` Taco Hoekwater
@ 2006-08-04 12:27         ` Peter Rolf
  2006-08-04 12:42           ` Taco Hoekwater
  2006-08-04 14:26         ` Peter Rolf
  1 sibling, 1 reply; 12+ messages in thread
From: Peter Rolf @ 2006-08-04 12:27 UTC (permalink / raw)


Taco Hoekwater wrote:
> Taco Hoekwater wrote:
>> Hi Peter,
>>
>> Peter Rolf wrote:
>>
>>> If someone can solve this problem I would be very glad.
>>
>> Adding a semicolon after the 'endgroup' command removes
>> the error.
> 
_Thank you very much, Taco!_ I have spent several hours to fix this MP
error, without any success. The resulting docs looked ok, but if you
have 50 or more MP graphics, you can't hit 'q' every time.

BTW: Why do I need a semicolon after 'endgroup', but (in most cases) not
after 'fi', 'endfor'?

> (I just looked at your pdf document).
> 
> You probably want 'useMPgraphic' instead of 'uniqueMPgraphic'.
> 
I'm not sure what you mean. Using 'useMPgraphic' to load all kind of MP
graphics?

I must try the latest beta... :)

Peter

> Taco
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context
> 
> 

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

* Re: TeX trigger in MP macro
  2006-08-04 12:27         ` Peter Rolf
@ 2006-08-04 12:42           ` Taco Hoekwater
  2006-08-04 13:04             ` Peter Rolf
  0 siblings, 1 reply; 12+ messages in thread
From: Taco Hoekwater @ 2006-08-04 12:42 UTC (permalink / raw)




Peter Rolf wrote:
> BTW: Why do I need a semicolon after 'endgroup', but (in most cases) not
> after 'fi', 'endfor'?

You need a semicolon at the end of a statement. The <if> and <loop>
constructs are not statements, they are preprocessed.

You get the 'extra tokens' error when Metapost sees something like

	endgroup a:=1;

because it knows that 'endgroup' can only be a statement on its own.

> 
>>(I just looked at your pdf document).
>>
>>You probably want 'useMPgraphic' instead of 'uniqueMPgraphic'.
>>
> 
> I'm not sure what you mean. Using 'useMPgraphic' to load all kind of MP
> graphics?

You have to use \startuseMPgraphic and \useMPgraphic instead of
\startuniqueMPgraphic, otherwise the output of both images will be
identical.

Cheers, Taco

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

* Re: TeX trigger in MP macro
  2006-08-04 12:42           ` Taco Hoekwater
@ 2006-08-04 13:04             ` Peter Rolf
  0 siblings, 0 replies; 12+ messages in thread
From: Peter Rolf @ 2006-08-04 13:04 UTC (permalink / raw)


Taco Hoekwater wrote:
> 
> Peter Rolf wrote:
>> BTW: Why do I need a semicolon after 'endgroup', but (in most cases) not
>> after 'fi', 'endfor'?
> 
> You need a semicolon at the end of a statement. The <if> and <loop>
> constructs are not statements, they are preprocessed.
> 
> You get the 'extra tokens' error when Metapost sees something like
> 
> 	endgroup a:=1;
> 
> because it knows that 'endgroup' can only be a statement on its own.
> 
I see. A day of insight :)

>>> (I just looked at your pdf document).
>>>
>>> You probably want 'useMPgraphic' instead of 'uniqueMPgraphic'.
>>>
>> I'm not sure what you mean. Using 'useMPgraphic' to load all kind of MP
>> graphics?
> 
> You have to use \startuseMPgraphic and \useMPgraphic instead of
> \startuniqueMPgraphic, otherwise the output of both images will be
> identical.
> 
Again stupid me. If the size of the overlay does not change, the graphic
does not. So this was a 'bad' example (but now the beta runs like a
charm). Thanks Taco.

Greetings, Peter

> Cheers, Taco
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context
> 
> 

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

* Re: TeX trigger in MP macro
  2006-08-04 11:17       ` Taco Hoekwater
  2006-08-04 12:27         ` Peter Rolf
@ 2006-08-04 14:26         ` Peter Rolf
  2006-08-04 14:42           ` stange error in Live ConTeXt Taco Hoekwater
  1 sibling, 1 reply; 12+ messages in thread
From: Peter Rolf @ 2006-08-04 14:26 UTC (permalink / raw)


Taco Hoekwater wrote:
> Taco Hoekwater wrote:
>> Hi Peter,
>>
>> Peter Rolf wrote:
>>
>>> If someone can solve this problem I would be very glad.
>>
>> Adding a semicolon after the 'endgroup' command removes
>> the error.
> 
> (I just looked at your pdf document).
> 
> You probably want 'useMPgraphic' instead of 'uniqueMPgraphic'.
> 
> Taco
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context
> 
> 
The following code works here, but not at context live. What have I done
now? ;)

Peter


 TeXExec 5.4.3 - ConTeXt / PRAGMA ADE 1997-2005

               texexec : TeXExec 5.4.3 - ConTeXt / PRAGMA ADE 1997-2005
               texutil : TeXUtil 9.0.1 - ConTeXt / PRAGMA ADE 1992-2006
                   tex : pdfTeX, 3.141592-1.40.0-beta-20060213 (Web2C 7.5.5)
               context : ver: 2006.08.02 23:31
               cont-en : ver: 2006.08.02 23:31  fmt: 2006.8.4  mes: en




% interface=en output=pdftex
% Time-stamp: <Freitag, 04 August 2006 15:58:06; test.tex>
%
\setupcolors[state=start]

\def\DbgFill{0}

\startMPinclusions
def dbg_fill (text p) =
  if (\DbgFill=0) :
    fill p ;
  fi
enddef ;
\stopMPinclusions


\startuseMPgraphic{My_SquareA}
begingroup
  if (\DbgFill=0) :
    fill OverlayBox withcolor green ;
  fi
endgroup ;
\stopuseMPgraphic

\defineoverlay[MySquareA]
[\useMPgraphic{My_SquareA}]


\startuseMPgraphic{My_SquareB}
begingroup
  dbg_fill(OverlayBox withcolor yellow) ;
endgroup ;
\stopuseMPgraphic

\defineoverlay[MySquareB]
[\useMPgraphic{My_SquareB}]



\starttext

\def\DbgFill{0}
{\bf DbgFill=0:}

\framed[background=MySquareA]{TestA}
\framed[background=MySquareB]{TestB}

\def\DbgFill{1}
{\bf DbgFill=1:}

\framed[background=MySquareA]{TestA}
\framed[background=MySquareB]{TestB}


\stoptext

%%% Local Variables:
%%% mode: context
%%% TeX-master: ""
%%% End:

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

* stange error in Live ConTeXt
  2006-08-04 14:26         ` Peter Rolf
@ 2006-08-04 14:42           ` Taco Hoekwater
  2006-08-04 16:22             ` Peter Rolf
  2006-09-06 18:54             ` Patrick Gundlach
  0 siblings, 2 replies; 12+ messages in thread
From: Taco Hoekwater @ 2006-08-04 14:42 UTC (permalink / raw)



Hi Peter and "Author of Live.contextgarden.net",

Peter Rolf wrote:
> 
> The following code works here, but not at context live. What have I done
> now? ;)

Not something you did ;-)

Your first comment line is confusing the Live setup. This extremely
minimal example fails as well:

   % interface=en output=pdftex
   \starttext
   Hello
   \stoptext


Cheers, Taco

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

* Re: stange error in Live ConTeXt
  2006-08-04 14:42           ` stange error in Live ConTeXt Taco Hoekwater
@ 2006-08-04 16:22             ` Peter Rolf
  2006-09-06 18:54             ` Patrick Gundlach
  1 sibling, 0 replies; 12+ messages in thread
From: Peter Rolf @ 2006-08-04 16:22 UTC (permalink / raw)


Hi Taco (debugging grandmaster),

Taco Hoekwater wrote:
> Hi Peter and "Author of Live.contextgarden.net",
>
:)

I have a real special ConTeXt installation (85MB in a ramdisk; eshell),
so live.contextgarden.net is a good place to check code on a more
'normal' platform. Using context live I can simply see if it's my
problem (most too often) or a general one.

Thanks again and also to Patrick for this really nice feature.

Greetings, Peter

> Peter Rolf wrote:
>> The following code works here, but not at context live. What have I done
>> now? ;)
> 
> Not something you did ;-)
> 
> Your first comment line is confusing the Live setup. This extremely
> minimal example fails as well:
> 
>    % interface=en output=pdftex
>    \starttext
>    Hello
>    \stoptext
> 
> 
> Cheers, Taco
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context
> 
> 

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

* Re: stange error in Live ConTeXt
  2006-08-04 14:42           ` stange error in Live ConTeXt Taco Hoekwater
  2006-08-04 16:22             ` Peter Rolf
@ 2006-09-06 18:54             ` Patrick Gundlach
  1 sibling, 0 replies; 12+ messages in thread
From: Patrick Gundlach @ 2006-09-06 18:54 UTC (permalink / raw)


Hi Taco,


Taco Hoekwater <taco@elvenkind.com> writes:

> Hi Peter and "Author of Live.contextgarden.net",
>
> Peter Rolf wrote:
>> The following code works here, but not at context live. What have I
>> done
>> now? ;)
>
> Not something you did ;-)
>
> Your first comment line is confusing the Live setup. This extremely
> minimal example fails as well:
>
>    % interface=en output=pdftex
>    \starttext
>    Hello
>    \stoptext

Hmm, I can't see anything wrong at live.contextgarden.net with the
simple code. Should live ignore the % comment line?

Patrick
-- 
ConTeXt wiki and more: http://contextgarden.net

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

end of thread, other threads:[~2006-09-06 18:54 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-03 12:29 TeX trigger in MP macro Peter Rolf
2006-08-03 23:01 ` Hans Hagen
2006-08-04 10:57   ` Peter Rolf
2006-08-04 11:14     ` Taco Hoekwater
2006-08-04 11:17       ` Taco Hoekwater
2006-08-04 12:27         ` Peter Rolf
2006-08-04 12:42           ` Taco Hoekwater
2006-08-04 13:04             ` Peter Rolf
2006-08-04 14:26         ` Peter Rolf
2006-08-04 14:42           ` stange error in Live ConTeXt Taco Hoekwater
2006-08-04 16:22             ` Peter Rolf
2006-09-06 18:54             ` Patrick Gundlach

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