ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* \doifelse inside MP(code|graphic)
@ 2008-11-18  6:33 Aditya Mahajan
  2008-11-18  8:47 ` Taco Hoekwater
  0 siblings, 1 reply; 4+ messages in thread
From: Aditya Mahajan @ 2008-11-18  6:33 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi,

\doifelse does not work inside any MP environment. Something really 
strange happens if you try to use it. \loggingall tells me what exactly is 
happening, but I do not know enough low-level TeX to understand why this 
is happening.

Conside this test file

%----------------------
\def\test{string}
\starttext
\doifelse{\test}{string}{test is a string}{or not}
\loggingall
\startMPcode
   draw \doifelse{\test}{string}{fullcircle}{fullsquare} scaled 5cm ;
\stopMPcode
\stoptext
%------------------------

It does not compile correctly. Intesting pieces from the log file 
(actually the MKII log, since that is more interesting)

\dostartMPcode #1\stopMPcode ->\startuseMPgraphic {@@}#1\stopuseMPgraphic 
\useMPgraphic {@@}\endgroup
#1<-draw \doifelse {\test }{string}{fullcircle}{fullsquare} scaled 5cm ;

...

\doifelse #1#2->\edef \!!stringa {#1}\edef \!!stringb {#2}\ifx \!!stringa 
\!!stringb \expandafter \firstoftwoarguments \else \expandafter 
\secondoftwoargument
s \fi
#1<-\test
#2<-string

\!!stringa ->currentcolor

\test ->string

\!!stringb ->black
{no mode: \ifx: (level 5) entered on line 11}
{false}
{\else: \ifx (level 5) entered on line 11}
{\expandafter}
{\fi: \ifx (level 5) entered on line 11}

.....

\ascii ->
draw \edef currentcolor{string}\edef black{string}fullsquare scaled 5cm ;
{changing \MPascii=undefined}
{into \MPascii=macro:->
draw \edef currentcolor{string\ETC.}
{\the}


Notice the first line of \ascii, and compare that with the definition of
\doifelse. The command \!!stringa inside the definition of \doifelse gets
expanded too soon. Is there any way to get this work, other than doing the
comparison outside the MP code.

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://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

end of thread, other threads:[~2008-11-18 15:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-18  6:33 \doifelse inside MP(code|graphic) Aditya Mahajan
2008-11-18  8:47 ` Taco Hoekwater
2008-11-18  9:06   ` Hans Hagen
2008-11-18 15:45     ` 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).