![](https://secure.gravatar.com/avatar/9e99447a6bae0dd65f2cdf61e8a46f4e.jpg?s=120&d=mm&r=g)
Hi, How can test whether a variable has been set? I couldn't find any reference to this in the wiki? TIA, Elliot
![](https://secure.gravatar.com/avatar/44ca9eda7aaa681c0e3b3e90125c56b0.jpg?s=120&d=mm&r=g)
Hi Elliot, Elliot Clifton schrieb:
Hi,
How can test whether a variable has been set? I couldn't find any reference to this in the wiki?
What do you mean by "set"? I use \doifnothing{\getvariable{foo}{bar}} {foo:bar contains nothing.\par}% \doifsomething{\getvariable{foo}{bar}} {foo:bar contains something.\par}% \doifelsenothing{\getvariable{foo}{bar}} {foo:bar contains nothing.\par} {foo:bar contains something.\par}% to test, if a defined(!) variable contains something. If you want to test if a variable is defined, you can use \doifnotvariable{foo}{bar} {foo:bar is undefined.\par}% \doifvariable{foo}{bar} {foo:bar is defined.\par}% \doifelsevariable{foo}{bar} {foo:bar is defined.\par} {foo:bar is undefined.\par}% Never used these macros, as I always define default values for my variables. HTH, Peter
TIA,
Elliot ___________________________________________________________________________________ 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 : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
participants (2)
-
Elliot Clifton
-
Peter Rolf