# Different content if command returns empty text (ConTeXt)

I have the following code in my ConTeXt environment:

\startsetups[sectioninfo]
\ss
\rlap{\userpagenumber}
\hfill
§ \getmarking[sectionnumber][current]
\emspace
\bf \getmarking[section][current]
\hfill
\llap{}
\stopsetups

[]                    [\setups{sectioninfo}]

My intention here is pretty simple; I want the page number on the left and the section name in the middle. However, if there's no section defined in this chapter yet, it will show the name of the last section defined in the previous chapter, or the one before that, and so forth, which is undesirable. It's also undesirable in the front matter, where no sections have yet been defined, to see the § in the header.

1. How does one conditionally display one thing or another, in particular if one thing is blank or empty in some sense? I think I mean this in a TeX sense primarily, but if there's a ConTeXt-specific way of doing this, that's fine too.
2. How does one determine if \getmarking[section][current] is giving me something from the previous chapter, or is there a different parameter to \getmarking that can be passed to get the most recent section in this chapter only?

Any resources you can point me towards would be greatly appreciated! Thanks!

-

To the first question, there is a command \doiftextelse. I've replaced my definition of sectioninfo using it to solve the first part:

\startsetups[sectioninfo]
\ss
\rlap{\userpagenumber}
\hfill
\doiftextelse{\getmarking[section][current]}
{§ \getmarking[sectionnumber][current]
\emspace
\bf \getmarking[section][current]}
{}
\hfill
\llap{}
\stopsetups

So, in short, \doiftextelse{condition}{true-case}{false-case}. Wolfgang Schuster helpfully supplied this answer on the NTG-ConTeXt mailing list. However, I still don't know where commands like this are defined and where to learn how to write them. This is information I would love to have.

As to the second problem, I don't know what I'm doing wrong in my document, but I can't create a short example of it, so it must be something glitchy in my environment. In the meantime, I've come up with a kludge that seems to solve the problem, which is:

The only reliable way to understand low level commands like \doiftextelse is to read the source documentation. Luigi Scarsgo maintains the typeset version of the source, but that is slightly old. You can also generate the documentation on your own using  mtxrun --script modules --process kpse:supp-box.mkiv which will generate supp-box-mkiv.pdf which includes, among other things, a terse documentation of doiftextelse. –  Aditya Feb 16 '11 at 22:49