I would like to differentiate on the following character being one of X or not X. But cannot get it right in \doifnextcharelse. For example \def\mynextchar{\doifnextcharelse{X}{\def\Next{Y}}{\def\Next{Z}}\Next} delivers: ZX ZQ then input: \mynextchar X \mynextchar Q I hoped for YX ZQ, but it looks as if X tested false against X. How to? Hans van der Meer
On 01/24/2016 02:30 PM, dr. Hans van der Meer wrote:
I would like to differentiate on the following character being one of X or not X. But cannot get it right in \doifnextcharelse.
For example \def\mynextchar{\doifnextcharelse{X}{\def\Next{Y}}{\def\Next{Z}}\Next} delivers: ZX ZQ then input: \mynextchar X \mynextchar Q I hoped for YX ZQ, but it looks as if X tested false against X.
How to?
Hans, the basic \def\mynextchar{\doifnextcharelse{x}{y}{z}} works. With your sample: \def\mynextchar{ \doifnextcharelse{X} {\def\Next{Y}\Next} {\def\Next{Z}\Next}} I hope it helps, Pablo -- http://www.ousia.tk
Yes this works. But alas, the ultimate goal is to test against several characters and that seems impossible to do with standard ConTeXt api-macros.Let alone when these characters are . or . or ) etc. Hans van der Meer met vriendelijke groet Hans van der Meer
On 24 Jan 2016, at 15:13, Pablo Rodriguez
wrote: On 01/24/2016 02:30 PM, dr. Hans van der Meer wrote:
I would like to differentiate on the following character being one of X or not X. But cannot get it right in \doifnextcharelse.
For example \def\mynextchar{\doifnextcharelse{X}{\def\Next{Y}}{\def\Next{Z}}\Next} delivers: ZX ZQ then input: \mynextchar X \mynextchar Q I hoped for YX ZQ, but it looks as if X tested false against X.
How to?
Hans,
the basic \def\mynextchar{\doifnextcharelse{x}{y}{z}} works.
With your sample:
\def\mynextchar{ \doifnextcharelse{X} {\def\Next{Y}\Next} {\def\Next{Z}\Next}}
I hope it helps,
Pablo -- http://www.ousia.tk
Is it impossible to test on a blank with something alike \doifnextcharelse ? The implementation in the source skips blanks, but what if that is one doesn't want? For example to distinguish between "\abc \def" and \abc\def"? Hans van der Meer
Meer, Hans van der mailto:H.vanderMeer@uva.nl 24. Januar 2016 um 15:58 Yes this works. But alas, the ultimate goal is to test against several characters and that seems impossible to do with standard ConTeXt api-macros.Let alone when these characters are . or . or ) etc. \startluacode
function checknextstring(str) if str == "a" then context("A") elseif str == "b" then context("B") else context("??") end end interfaces.implement { name = "readnextstring", actions = checknextstring, arguments = "string" } \stopluacode \unprotect \let\readnextstring\clf_readnextstring \protect \starttext \readnextstring c \readnextstring b \readnextstring a \readnextstring {xx} \stoptext Wolfgang
participants (4)
-
dr. Hans van der Meer
-
Meer, Hans van der
-
Pablo Rodriguez
-
Wolfgang Schuster