How to reliably check if a document variable is not empty in ConTeXt?
up vote
3
down vote
favorite
Consider the following MWE:
startdocument[title=]
doifemptyvariableelse{document}{title}{True}{documentvariable{title}}
Test
stopdocument
So basically I have a document with a title variable. Now I want to check if that variable is empty (doifemptyvariableelse
). Instead of simply outputting the right branch and exiting the current code gobbles the next two tokens, which feels wrong.
Is there some easy approach to check whether a document variable is empty that does not gobble following tokens?
context
add a comment |
up vote
3
down vote
favorite
Consider the following MWE:
startdocument[title=]
doifemptyvariableelse{document}{title}{True}{documentvariable{title}}
Test
stopdocument
So basically I have a document with a title variable. Now I want to check if that variable is empty (doifemptyvariableelse
). Instead of simply outputting the right branch and exiting the current code gobbles the next two tokens, which feels wrong.
Is there some easy approach to check whether a document variable is empty that does not gobble following tokens?
context
@Marco Well, I usually consultsetup-en.pdf
to see the available commands and it does not listdoifdocumentvariable
. The wiki also does not mention the new commands. Would you like to add an answer?
– TeXnician
Nov 18 at 16:19
Done. I can't for sure say whydoifemptyvariable
doesn't work in this case. It has something to do with how the argument is constructed, I believe. But I leave that part to the experts.
– Marco
Nov 18 at 16:31
a)doifemptyvariableelse
doesn’t work because there is a bug (wrong number of arguments) for theTRUE
case. b) The commands will be added to setup-en.pdf (If you miss a command in the document you can send a message to the ConTeXt mailing list or the author of the document).
– Wolfgang Schuster
Nov 18 at 22:34
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
Consider the following MWE:
startdocument[title=]
doifemptyvariableelse{document}{title}{True}{documentvariable{title}}
Test
stopdocument
So basically I have a document with a title variable. Now I want to check if that variable is empty (doifemptyvariableelse
). Instead of simply outputting the right branch and exiting the current code gobbles the next two tokens, which feels wrong.
Is there some easy approach to check whether a document variable is empty that does not gobble following tokens?
context
Consider the following MWE:
startdocument[title=]
doifemptyvariableelse{document}{title}{True}{documentvariable{title}}
Test
stopdocument
So basically I have a document with a title variable. Now I want to check if that variable is empty (doifemptyvariableelse
). Instead of simply outputting the right branch and exiting the current code gobbles the next two tokens, which feels wrong.
Is there some easy approach to check whether a document variable is empty that does not gobble following tokens?
context
context
asked Nov 18 at 15:23
TeXnician
23.4k62984
23.4k62984
@Marco Well, I usually consultsetup-en.pdf
to see the available commands and it does not listdoifdocumentvariable
. The wiki also does not mention the new commands. Would you like to add an answer?
– TeXnician
Nov 18 at 16:19
Done. I can't for sure say whydoifemptyvariable
doesn't work in this case. It has something to do with how the argument is constructed, I believe. But I leave that part to the experts.
– Marco
Nov 18 at 16:31
a)doifemptyvariableelse
doesn’t work because there is a bug (wrong number of arguments) for theTRUE
case. b) The commands will be added to setup-en.pdf (If you miss a command in the document you can send a message to the ConTeXt mailing list or the author of the document).
– Wolfgang Schuster
Nov 18 at 22:34
add a comment |
@Marco Well, I usually consultsetup-en.pdf
to see the available commands and it does not listdoifdocumentvariable
. The wiki also does not mention the new commands. Would you like to add an answer?
– TeXnician
Nov 18 at 16:19
Done. I can't for sure say whydoifemptyvariable
doesn't work in this case. It has something to do with how the argument is constructed, I believe. But I leave that part to the experts.
– Marco
Nov 18 at 16:31
a)doifemptyvariableelse
doesn’t work because there is a bug (wrong number of arguments) for theTRUE
case. b) The commands will be added to setup-en.pdf (If you miss a command in the document you can send a message to the ConTeXt mailing list or the author of the document).
– Wolfgang Schuster
Nov 18 at 22:34
@Marco Well, I usually consult
setup-en.pdf
to see the available commands and it does not list doifdocumentvariable
. The wiki also does not mention the new commands. Would you like to add an answer?– TeXnician
Nov 18 at 16:19
@Marco Well, I usually consult
setup-en.pdf
to see the available commands and it does not list doifdocumentvariable
. The wiki also does not mention the new commands. Would you like to add an answer?– TeXnician
Nov 18 at 16:19
Done. I can't for sure say why
doifemptyvariable
doesn't work in this case. It has something to do with how the argument is constructed, I believe. But I leave that part to the experts.– Marco
Nov 18 at 16:31
Done. I can't for sure say why
doifemptyvariable
doesn't work in this case. It has something to do with how the argument is constructed, I believe. But I leave that part to the experts.– Marco
Nov 18 at 16:31
a)
doifemptyvariableelse
doesn’t work because there is a bug (wrong number of arguments) for the TRUE
case. b) The commands will be added to setup-en.pdf (If you miss a command in the document you can send a message to the ConTeXt mailing list or the author of the document).– Wolfgang Schuster
Nov 18 at 22:34
a)
doifemptyvariableelse
doesn’t work because there is a bug (wrong number of arguments) for the TRUE
case. b) The commands will be added to setup-en.pdf (If you miss a command in the document you can send a message to the ConTeXt mailing list or the author of the document).– Wolfgang Schuster
Nov 18 at 22:34
add a comment |
1 Answer
1
active
oldest
votes
up vote
4
down vote
accepted
You can use doifdocumentvariableelse
(defined in file-job.mkvi
), which uses doifsomething
. Example:
startdocument[title=]
doifdocumentvariableelse{title}{documentvariable{title}}{False}
%% is the same as:
%% doifsomethingelse{documentvariable{title}}{documentvariable{title}}{False}
Test
stopdocument
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
You can use doifdocumentvariableelse
(defined in file-job.mkvi
), which uses doifsomething
. Example:
startdocument[title=]
doifdocumentvariableelse{title}{documentvariable{title}}{False}
%% is the same as:
%% doifsomethingelse{documentvariable{title}}{documentvariable{title}}{False}
Test
stopdocument
add a comment |
up vote
4
down vote
accepted
You can use doifdocumentvariableelse
(defined in file-job.mkvi
), which uses doifsomething
. Example:
startdocument[title=]
doifdocumentvariableelse{title}{documentvariable{title}}{False}
%% is the same as:
%% doifsomethingelse{documentvariable{title}}{documentvariable{title}}{False}
Test
stopdocument
add a comment |
up vote
4
down vote
accepted
up vote
4
down vote
accepted
You can use doifdocumentvariableelse
(defined in file-job.mkvi
), which uses doifsomething
. Example:
startdocument[title=]
doifdocumentvariableelse{title}{documentvariable{title}}{False}
%% is the same as:
%% doifsomethingelse{documentvariable{title}}{documentvariable{title}}{False}
Test
stopdocument
You can use doifdocumentvariableelse
(defined in file-job.mkvi
), which uses doifsomething
. Example:
startdocument[title=]
doifdocumentvariableelse{title}{documentvariable{title}}{False}
%% is the same as:
%% doifsomethingelse{documentvariable{title}}{documentvariable{title}}{False}
Test
stopdocument
answered Nov 18 at 16:29
Marco
23.9k26797
23.9k26797
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f460607%2fhow-to-reliably-check-if-a-document-variable-is-not-empty-in-context%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
@Marco Well, I usually consult
setup-en.pdf
to see the available commands and it does not listdoifdocumentvariable
. The wiki also does not mention the new commands. Would you like to add an answer?– TeXnician
Nov 18 at 16:19
Done. I can't for sure say why
doifemptyvariable
doesn't work in this case. It has something to do with how the argument is constructed, I believe. But I leave that part to the experts.– Marco
Nov 18 at 16:31
a)
doifemptyvariableelse
doesn’t work because there is a bug (wrong number of arguments) for theTRUE
case. b) The commands will be added to setup-en.pdf (If you miss a command in the document you can send a message to the ConTeXt mailing list or the author of the document).– Wolfgang Schuster
Nov 18 at 22:34