On Thu, 28 Feb 2019, Procházka Lukáš Ing. wrote:

Hello,

I'm struggling with using modes to make a part of the text conditional.

Here is my code:

----
\def\b#1{\startmode[#1]}
\def\e{\stopmode}

% \enablemode[100] % For optional usage

\starttext
A
\b{100} % Should be start of some conditional text from here ...
  B
\e % ... to here
\stoptext

Modes don't work that way. You can do something like this:

\define[1]\bbb
    {\doifnotmode{#1}
        {\grabbufferdata[dummy][bbb][eee]}}

\let\eee\relax

\enablemode[100]

\starttext
A

\bbb{100}
  Inside mode 100
\eee

\bbb{101}
  Inside mode 101
\eee

\stoptext


Depending on the actual use case, there might be simpler ways.

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
___________________________________________________________________________________

Reply via email to