The macros in the conditionals package are by Donald Arsenau and according to the commentary in the package they are public domain.
So here they are:
{\catcode`\!=8 % funny catcode so ! will be a delimiter
\catcode`\Q=3 % funny catcode so Q will be a delimiter
\long\gdef\given#1{88\fi\Ifbl@nk#1QQQ\empty!}
\long\gdef\blank#1{88\fi\Ifbl@nk#1QQ..!}% if null or spaces
\long\gdef\nil#1{\IfN@Ught#1* {#1}!}% if null
\long\gdef\IfN@Ught#1 #2!{\blank{#2}}
\long\gdef\Ifbl@nk#1#2Q#3!{\ifx#3}% same as above
}
Surround the code by \makeatletter and \makeatother if you want to use them in your document.
Let's see what happens when \if\blank{<tokens>}<TRUE>\else<FALSE>\fi is expanded, concentrating on the \if\blank{<tokens>} part. Usually <tokens> will be the argument to a macro.
One has to know that \if continues expansion until it finds two unexpandable tokens after it, of which it compares the character code. So the first expansion is
\if88\fi\Ifbl@nk<tokens>QQ..!
and \if compares 8 with 8; the \fi closes the conditional which does nothing at all! It's just there to allow the construction to be nested with other conditionals. Now TeX finds
\Ifbl@nk<tokens>QQ..!
If <tokens> consists only of (zero or more) spaces, the search for the first (undelimited) argument to \Ifbl@nk will bypass them. In this case argument #1 will be Q3 (the subscript denotes the funny category code), argument #2 will be empty and argument #3 will be .., so finally we'll have
\ifx..<TRUE>\else<FALSE>\fi
which will choose the true branch. Suppose now that in <tokens> there is a non space token. The first such token (or braced group) will become the first argument to \Ifbl@nk, while the rest will be argument #2. So anything up to !8 will be argument #3, that is Q.. so TeX will see
\ifx Q..<TRUE>\else<FALSE>\fi
and the comparison is between Q3 and .12 which are different, so the trailing period will vanish with the ignored true branch and the false branch will be followed.
Note that no expansion of <tokens> takes place; this list of tokens disappears completely.
With \if\given{<tokens>}, after the same \if88\fi that disappears, TeX finds
\Ifbl@nk<tokens>QQQ\empty!
Again, if <tokens> consists of (zero or more) spaces, these will be bypassed and argument #1 will be Q, argument #2 will be empty and argument #3 will be Q\empty; so TeX will see
\ifx Q\empty<TRUE>\else<FALSE>\fi
thus following the false branch. If some non blank token appears in <tokens> the first one (or the first braced group) will be #1, the rest will be #2 and #3 will be QQ\empty. In this case TeX will see
\ifx QQ\empty<TRUE>\else<FALSE>\fi
so \empty starts the true branch, but its expansion is empty and is (almost) irrelevant.
Last, \if\nil{<tokens>}. After \if88\fi we get
\IfN@Ught<tokens>* {<tokens>}!
Now leading blank tokens in <tokens> will not be bypassed, because the first argument to \IfN@Ught is delimited by a space. Everything after a leading space will become #2 and at least * is there, so \blank{#2} will return false. If the first token in <tokens> is not a space, at least {<tokens>} will become part of #2, so that \blank{#2} will return false as well.
Thus the only way \if\nil{<tokens>} can return true is that <tokens> is really empty (no tokens at all).
Very clever macros indeed!
Alternative 1
Use etoolbox that provides
\ifstrempty{<tokens>}{<true>}{<false>}
\ifblank{<tokens>}{<true>}{<false>}
\notblank{<tokens>}{<true>}{<false>}
that are equivalent to
\if\nil{<tokens>}
\if\blank{<tokens>}
\if\given{<tokens>}
respectively, but with a different syntax (no \else and \fi). The footnote to the documentation in etoolbox says that the macros are based on code by Donald Arsenau, which quite probably is the same as in conditionals.sty.
Alternative 2
In LaTeX3 there are similar constructs:
\tl_if_empty:nTF {<tokens>}{<TRUE>}{<FALSE>}
is the same as \if\nil{<tokens>}, while
\tl_if_blank:nTF {<tokens>}{<TRUE>}{<FALSE>}
is the same as \if\blank{<tokens>}. Of course the syntax is similar to the one in etoolbox. There's actually no need for an analogous to \if\given{<tokens>}.
conditionals.styis part of thesongbookpackage. However, there is no documentation with the latter about conditionals. I'd therefore suggest you want to look at something likeetoolbox: perhaps you could focus the question on the test you need rather than what seems to be an obscure support package. – Joseph Wright Jan 22 '13 at 21:49ifthen. – Joseph Wright Jan 22 '13 at 21:56\if\blank{\myMacro}is most definitively wrong. This is not how the\ifprimitive works. I think you means some\ifblankmacro instead. – Martin Scharrer Jan 22 '13 at 21:58\blank{\myMacro}expands to01or11depending on whether\myMacroisblankor not... (or rather the contrary) – Jan 22 '13 at 22:11\if, and even make sense if you want to work with\if.. \else \fiinstead with a\@if..{..}{..}construct. – Martin Scharrer Jan 22 '13 at 22:13\if\blank{...}is the syntax used and I also expect it to expand to either01or11. And the reason I like it is really the one you mentioned: I prefer to work with\if.. \else \firather then\@if..{..}{..}. I have programming background so that fits me better. My problem is that that blank command seems not to work with macros. So while\if\blank{#1}works correctly,\if\blank{\myEmpty}does not. – Rasto Jan 22 '13 at 23:02