Re: [NTG-context] Failing \doifemptyelse

2022-06-24 Thread Willi Egger via ntg-context
Hans, Wolfgang!

Thank you so much for your instructions! — This expansion thing is something I 
will probably never master ;-(

Thank you!
Kind regards
Willi

> On 24 Jun 2022, at 05:42, Wolfgang Schuster via ntg-context 
>  wrote:
> 
> Hans Hagen via ntg-context schrieb am 23.06.2022 um 23:00:
>> On 6/23/2022 9:16 PM, Willi Egger via ntg-context wrote:
>>> Good evening gurus!
>>> 
>>> Why is the minimal example failing? i.e. executing always the else-branch?
>>> 
>>> \setuppapersize[A6][A6]
>>> 
>>> \setvariables
>>>[Test]
>>>[Number=]
>>> 
>>> 
>>> \starttext
>>>Value of variable Number before test: \getvariable{Test}{Number} \crlf
>>> 
>>>  \doifemptyelse{\getvariable{Test}{Number}}
>>>{\dorecurse
>>> {5}
>>> {TEST}
>>>}
>>>{Nothing defined \par
>>> Contents of variable Number: \getvariable{Test}{Number}
>>>}
>>> 
>>> \stoptex
>> there's also
>> 
>> \doifelsevariable {Test} {Number}
>> 
>> that can be used
> 
> in this case
> 
> \doifelseemptyvariable{Test}{Number}{...}{...}
> 
> is the better choice
> 
> Wolfgang
> 
> ___
> 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
> ___

___
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
___


Re: [NTG-context] Failing \doifemptyelse

2022-06-23 Thread Wolfgang Schuster via ntg-context

Hans Hagen via ntg-context schrieb am 23.06.2022 um 23:00:

On 6/23/2022 9:16 PM, Willi Egger via ntg-context wrote:

Good evening gurus!

Why is the minimal example failing? i.e. executing always the 
else-branch?


\setuppapersize[A6][A6]

\setvariables
[Test]
[Number=]


\starttext
Value of variable Number before test: \getvariable{Test}{Number} 
\crlf


  \doifemptyelse{\getvariable{Test}{Number}}
    {\dorecurse
 {5}
 {TEST}
    }
    {Nothing defined \par
 Contents of variable Number: \getvariable{Test}{Number}
    }

\stoptex

there's also

\doifelsevariable {Test} {Number}

that can be used


in this case

\doifelseemptyvariable{Test}{Number}{...}{...}

is the better choice

Wolfgang

___
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
___


Re: [NTG-context] Failing \doifemptyelse

2022-06-23 Thread Hans Hagen via ntg-context

On 6/23/2022 9:16 PM, Willi Egger via ntg-context wrote:

Good evening gurus!

Why is the minimal example failing? i.e. executing always the else-branch?

\setuppapersize[A6][A6]

\setvariables
[Test]
[Number=]


\starttext
Value of variable Number before test: \getvariable{Test}{Number} \crlf

  \doifemptyelse{\getvariable{Test}{Number}}
{\dorecurse
{5}
{TEST}
}
{Nothing defined \par
 Contents of variable Number: \getvariable{Test}{Number}
}

\stoptex

there's also

\doifelsevariable {Test} {Number}

that can be used



-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-
___
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
___


Re: [NTG-context] Failing \doifemptyelse

2022-06-23 Thread Hans Hagen via ntg-context

On 6/23/2022 9:16 PM, Willi Egger via ntg-context wrote:

Good evening gurus!

Why is the minimal example failing? i.e. executing always the else-branch?

\setuppapersize[A6][A6]

\setvariables
[Test]
[Number=]


\starttext
Value of variable Number before test: \getvariable{Test}{Number} \crlf

  \doifemptyelse{\getvariable{Test}{Number}}
{\dorecurse
{5}
{TEST}
}
{Nothing defined \par
 Contents of variable Number: \getvariable{Test}{Number}
}

\stoptex

because that one doesn't expand the argument

\doifelsenothing
\doifelsesomething
\doifnothing
\doifsomething

can be used for your purpose

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-
___
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
___


Re: [NTG-context] Failing \doifemptyelse

2022-06-23 Thread Wolfgang Schuster via ntg-context

Willi Egger via ntg-context schrieb am 23.06.2022 um 21:16:

Good evening gurus!

Why is the minimal example failing? i.e. executing always the else-branch?


\doifempty(else) doesn't expand the argument and any argument counts as 
not empty. To satisfy the command you can expand the first argument 
(\normalexpanded) or you use \doifnothing(else) which expands the argument.


\starttext

\startbuffer
\doifemptyelse{}{YES}{NO}

\doifemptyelse{\empty}{YES}{NO}

\normalexpanded{\doifemptyelse{}}{YES}{NO}

\normalexpanded{\doifemptyelse{\empty}}{YES}{NO}

\doifnothingelse{}{YES}{NO}

\doifnothingelse{\empty}{YES}{NO}
\stopbuffer

\typebuffer \getbuffer

\stoptext

Wolfgang

___
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
___


[NTG-context] Failing \doifemptyelse

2022-06-23 Thread Willi Egger via ntg-context
Good evening gurus!

Why is the minimal example failing? i.e. executing always the else-branch?

\setuppapersize[A6][A6]

\setvariables
[Test]
[Number=]


\starttext
Value of variable Number before test: \getvariable{Test}{Number} \crlf

 \doifemptyelse{\getvariable{Test}{Number}}
{\dorecurse
{5}
{TEST}
}
{Nothing defined \par 
 Contents of variable Number: \getvariable{Test}{Number}
}

\stoptex


I am using ConTeXt version 2022.05.11 11:36 LMTX  fmt: 2022.6.15

Kind regards

Willi
___
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
___