9

I'm trying to debug some LaTeX3 code. To do so I would like to write the value of an internally generated boolean to the terminal, but I don't want to stop the work-flow of the LaTeX run.

For the sake of explanation, let's say the boolean is called

\l__my_private_boolean_bool

I don't want to do the following:

\bool_show:N \l__my_private_boolean_bool

because that stops everything.

Instead, I would like to do something like the following:

\msg_term:x { Boolean~value~is:~~\use:c {l__my_private_boolean_bool}} 

But what gets sent to the terminal is

Boolean value is: \__my_private_boolean_bool

I was expecting (and hoping) to see

Boolean value is:  false

or

Boolean value is:  true

Any suggestions?

EDIT

I've also tried:

\msg_term:x { Boolean~value~is:~~\cs_meaning:c {l__my_private_boolean_bool}} 

But then I get a cryptic

\char"0

printed to the screen.

MWE

This example does what I want, but what I would like to know is whether there is already a native LaTeX3 command that achieves the same thing as my \__ace_show_bool:N

\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\bool_new:N \l__ace_test_bool
\cs_new:Npn \__ace_show_bool:N #1 {
    \bool_if:nTF { #1 }
        { true }{ false }
}

\NewDocumentCommand{\testsetbool}{ m }{
    \str_if_eq:nnTF {true}{#1}
        {
            \bool_gset_true:N \l__ace_test_bool
        }
        {
            \bool_gset_false:N \l__ace_test_bool
        }
    \msg_term:x { Boolean~is:~~\__ace_show_bool:N \l__ace_test_bool }
}

\ExplSyntaxOff
\begin{document}

First \testsetbool{true}

Second \testsetbool{false}

Third \testsetbool{true}
\end{document}
3
  • While code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. Jan 31, 2013 at 3:41
  • Related Question: Using \typeout behaviour different with \newtoks vs. \def. Jan 31, 2013 at 3:41
  • @PeterGrill. Thanks for the link. But, I want to know how to do this in LaTeX3.
    – A.Ellett
    Jan 31, 2013 at 3:48

1 Answer 1

10

LaTeX3's bool data type is not implemented by simply storing true or false in a macro, and so you can't simple insert the variable name and expect it to print. Indeed, over time the underlying implementation has changed since there are alternative approaches with subtly-different benefits/issues. As such, the only 'correct' way to use them is in conditionals: inside \bool_show:N that is exactly what happens. So if you want to print the value of a bool, or store it inside some other variable, you need a conditional

\bool_if:NTF \l_my_bool
  { TRUE }
  { FALSE }

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .