* doifnextcharelse
@ 2016-01-24 13:30 dr. Hans van der Meer
2016-01-24 14:13 ` doifnextcharelse Pablo Rodriguez
0 siblings, 1 reply; 5+ messages in thread
From: dr. Hans van der Meer @ 2016-01-24 13:30 UTC (permalink / raw)
To: NTG ConTeXt
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
___________________________________________________________________________________
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 : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: doifnextcharelse
2016-01-24 13:30 doifnextcharelse dr. Hans van der Meer
@ 2016-01-24 14:13 ` Pablo Rodriguez
2016-01-24 14:58 ` doifnextcharelse Meer, Hans van der
0 siblings, 1 reply; 5+ messages in thread
From: Pablo Rodriguez @ 2016-01-24 14:13 UTC (permalink / raw)
To: mailing list for ConTeXt users
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
___________________________________________________________________________________
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 : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: doifnextcharelse
2016-01-24 14:13 ` doifnextcharelse Pablo Rodriguez
@ 2016-01-24 14:58 ` Meer, Hans van der
2016-01-24 18:15 ` doifnextcharelse Meer, Hans van der
2016-01-24 18:21 ` doifnextcharelse Wolfgang Schuster
0 siblings, 2 replies; 5+ messages in thread
From: Meer, Hans van der @ 2016-01-24 14:58 UTC (permalink / raw)
To: NTG ConTeXt
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 <oinos@gmx.es> 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
___________________________________________________________________________________
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 : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: doifnextcharelse
2016-01-24 14:58 ` doifnextcharelse Meer, Hans van der
@ 2016-01-24 18:15 ` Meer, Hans van der
2016-01-24 18:21 ` doifnextcharelse Wolfgang Schuster
1 sibling, 0 replies; 5+ messages in thread
From: Meer, Hans van der @ 2016-01-24 18:15 UTC (permalink / raw)
To: NTG ConTeXt
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
___________________________________________________________________________________
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 : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: doifnextcharelse
2016-01-24 14:58 ` doifnextcharelse Meer, Hans van der
2016-01-24 18:15 ` doifnextcharelse Meer, Hans van der
@ 2016-01-24 18:21 ` Wolfgang Schuster
1 sibling, 0 replies; 5+ messages in thread
From: Wolfgang Schuster @ 2016-01-24 18:21 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1.1: Type: text/plain, Size: 757 bytes --]
> 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
[-- Attachment #1.2: Type: text/html, Size: 1915 bytes --]
[-- Attachment #2: Type: text/plain, Size: 485 bytes --]
___________________________________________________________________________________
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 : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-01-24 18:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-24 13:30 doifnextcharelse dr. Hans van der Meer
2016-01-24 14:13 ` doifnextcharelse Pablo Rodriguez
2016-01-24 14:58 ` doifnextcharelse Meer, Hans van der
2016-01-24 18:15 ` doifnextcharelse Meer, Hans van der
2016-01-24 18:21 ` doifnextcharelse Wolfgang Schuster
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).