ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* special macro problem again...
@ 2005-03-07 20:00 Peter Münster
  2005-03-17 16:45 ` Peter Münster
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Münster @ 2005-03-07 20:00 UTC (permalink / raw)


Hello,
with the help by Hans, I've got a nice little macro "\MyMacro".
Now, I get another problem, when using "\doifmode" in the argument of this
macro. This is the error message: ! Incomplete \iffalse
And here the example file:

\newcount\MyVersion
\def\MyMacro#1{%
  \getgparameters[XXX][#1]
  \global\advance\MyVersion by 1
  \bTR \expanded{\bTD \the\MyVersion \eTD} \expanded{\bTD \XXXDate \eTD}\eTR
}
\starttext
\bTABLE
\bTR \bTD Version \eTD \bTD Date \eTD \eTR
\MyMacro{Date=1.2.2005}
\MyMacro{Date=\doifmode{abc}{3.4.2005}} % this does not work
\MyMacro{Date=5.6.2005}
\eTABLE

This works, but it is not so nice:

\doifmodeelse{abc}{%
  \def\DateOne{1111}%
  \def\DateTwo{2222}%
  \def\DateThree{3333}}{%
  \def\DateOne{4444}%
  \def\DateTwo{5555}%
  \def\DateThree{6666}}

\bTABLE
\bTR \bTD Version \eTD \bTD Date \eTD \eTR
\MyMacro{Date=\DateOne}
\MyMacro{Date=\DateTwo}
\MyMacro{Date=\DateThree}
\eTABLE

\stoptext


Could you help please?

Cheers, Peter

-- 
http://pmrb.free.fr/contact/

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

* Re: special macro problem again...
  2005-03-07 20:00 special macro problem again Peter Münster
@ 2005-03-17 16:45 ` Peter Münster
  2005-03-17 19:13   ` Taco Hoekwater
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Münster @ 2005-03-17 16:45 UTC (permalink / raw)


It's a repost.
Does anybody have an idea to solve this problem?
If not, I'm going to buy the TeXbook...

I try to expose the problem a bit clearer:

\newcount\MyVersion
\def\MyMacro#1{%     This macro is somewhere in an environment file.
  \getgparameters[XXX][#1]
  \global\advance\MyVersion by 1
  \bTR \expanded{\bTD \the\MyVersion \eTD} \expanded{\bTD \XXXNumber \eTD}\eTR
}

\def\MyNumber#1#2#3{% This macro is a special one for the document.
  \doifmode{aaa}{#1}\doifmode{bbb}{#2}\doifmode{ccc}{#3}}

\enablemode[bbb]

\starttext
\bTABLE
\bTR \bTD Version \eTD \bTD Number \eTD \eTR
\MyMacro{Number=123}
\MyMacro{Number=\MyNumber{111}{222}{333}} % error: Incomplete \iffalse
\MyMacro{Number=456}
\eTABLE
\stoptext

Greetings, Peter

-- 
http://pmrb.free.fr/contact/

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

* Re: special macro problem again...
  2005-03-17 16:45 ` Peter Münster
@ 2005-03-17 19:13   ` Taco Hoekwater
  2005-03-17 20:07     ` Peter Münster
  0 siblings, 1 reply; 4+ messages in thread
From: Taco Hoekwater @ 2005-03-17 19:13 UTC (permalink / raw)


Peter Münster wrote:
> It's a repost.
> Does anybody have an idea to solve this problem?
> If not, I'm going to buy the TeXbook...

This particular problem can be solved thus:

  \unexpanded\def\MyNumber#1#2#3{%
    \doifmode{aaa}{#1}\doifmode{bbb}{#2}\doifmode{ccc}{#3}}

There are some other syntactical possibilities, but the general
algorithm is always the same: making sure that the \expanded
within \MyMacro doesn't expand \doifmode, since \doifmode breaks
under pressure like that. You were not expected to know about that
(because this is undocumented), so you do not have to feel badly
about not owning a copy of the TeXbook. :-)

However, the TeXbook does explain the basic underlying problem,
and since the LaTeX Companion is not very helpful to ConTeXt
users <cough>, it is absolutely *the* book to buy.

Greetings, Taco


> I try to expose the problem a bit clearer:
> 
> \newcount\MyVersion
> \def\MyMacro#1{%     This macro is somewhere in an environment file.
>   \getgparameters[XXX][#1]
>   \global\advance\MyVersion by 1
>   \bTR \expanded{\bTD \the\MyVersion \eTD} \expanded{\bTD \XXXNumber \eTD}\eTR
> }
> 
> \def\MyNumber#1#2#3{% This macro is a special one for the document.
>   \doifmode{aaa}{#1}\doifmode{bbb}{#2}\doifmode{ccc}{#3}}
> 
> \enablemode[bbb]
> 
> \starttext
> \bTABLE
> \bTR \bTD Version \eTD \bTD Number \eTD \eTR
> \MyMacro{Number=123}
> \MyMacro{Number=\MyNumber{111}{222}{333}} % error: Incomplete \iffalse
> \MyMacro{Number=456}
> \eTABLE
> \stoptext
> 
> Greetings, Peter
> 

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

* Re: special macro problem again...
  2005-03-17 19:13   ` Taco Hoekwater
@ 2005-03-17 20:07     ` Peter Münster
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Münster @ 2005-03-17 20:07 UTC (permalink / raw)


On Thu, 17 Mar 2005, Taco Hoekwater wrote:

> This particular problem can be solved thus:
> 
>   \unexpanded\def\MyNumber#1#2#3{%
>     \doifmode{aaa}{#1}\doifmode{bbb}{#2}\doifmode{ccc}{#3}}

Thank you very much!

> However, the TeXbook does explain the basic underlying problem,
> and since the LaTeX Companion is not very helpful to ConTeXt
> users <cough>, it is absolutely *the* book to buy.

Yes, you're right, and probably I'll buy it one day. My real problem is,
that on the one hand I'm interested in ConTeXt and TeX, but on the other
hand my job has nothing to do with it, so I cannot spend much time looking
deeper insight these programs. Documentation is good, but experience too!

Greetings, Peter

-- 
http://pmrb.free.fr/contact/

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

end of thread, other threads:[~2005-03-17 20:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-07 20:00 special macro problem again Peter Münster
2005-03-17 16:45 ` Peter Münster
2005-03-17 19:13   ` Taco Hoekwater
2005-03-17 20:07     ` Peter Münster

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